forked from paritytech/parity-bridges-common
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
71 lines (57 loc) · 2.49 KB
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
# Builds images used by the bridge.
#
# In particular, it can be used to build Substrate nodes and bridge relayers. The binary that gets
# built can be specified with the `PROJECT` build-arg. For example, to build the `substrate-relay`
# you would do the following:
#
# `docker build . -t local/substrate-relay --build-arg=PROJECT=substrate-relay`
#
# See the `deployments/README.md` for all the available `PROJECT` values.
FROM docker.io/paritytech/bridges-ci:latest as builder
WORKDIR /parity-bridges-common
COPY . .
ARG PROJECT=substrate-relay
RUN cargo build --release --verbose -p ${PROJECT} && \
strip ./target/release/${PROJECT}
# In this final stage we copy over the final binary and do some checks
# to make sure that everything looks good.
FROM docker.io/library/ubuntu:20.04 as runtime
# show backtraces
ENV RUST_BACKTRACE 1
ENV DEBIAN_FRONTEND=noninteractive
RUN set -eux; \
apt-get update && \
apt-get install -y --no-install-recommends \
curl ca-certificates libssl-dev && \
update-ca-certificates && \
groupadd -g 1000 user && \
useradd -u 1000 -g user -s /bin/sh -m user && \
# apt clean up
apt-get autoremove -y && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*
# switch to non-root user
USER user
WORKDIR /home/user
ARG PROJECT=substrate-relay
COPY --chown=user:user --from=builder /parity-bridges-common/target/release/${PROJECT} ./
COPY --chown=user:user --from=builder /parity-bridges-common/deployments/local-scripts/bridge-entrypoint.sh ./
# check if executable works in this container
RUN ./${PROJECT} --version
ENV PROJECT=$PROJECT
ENTRYPOINT ["/home/user/bridge-entrypoint.sh"]
# metadata
ARG VCS_REF=master
ARG BUILD_DATE=""
ARG VERSION=""
LABEL org.opencontainers.image.title="${PROJECT}" \
org.opencontainers.image.description="${PROJECT} - component of Parity Bridges Common" \
org.opencontainers.image.source="https://github.com/paritytech/parity-bridges-common/blob/${VCS_REF}/Dockerfile" \
org.opencontainers.image.url="https://github.com/paritytech/parity-bridges-common/blob/${VCS_REF}/Dockerfile" \
org.opencontainers.image.documentation="https://github.com/paritytech/parity-bridges-common/blob/${VCS_REF}/README.md" \
org.opencontainers.image.created="${BUILD_DATE}" \
org.opencontainers.image.version="${VERSION}" \
org.opencontainers.image.revision="${VCS_REF}" \
org.opencontainers.image.authors="[email protected]" \
org.opencontainers.image.vendor="Parity Technologies" \
org.opencontainers.image.licenses="GPL-3.0 License"