|
1 | | -FROM phusion/baseimage:0.11 as builder |
2 | | -LABEL maintainer "xuliuchengxlc@gmail.com" |
3 | | -LABEL description="The build stage for ChainX. We create the ChainX binary in this stage." |
4 | | - |
5 | | -ARG PROFILE=release |
6 | | -ARG APP=chainx |
7 | | -ARG RUSTC_VERSION=nightly-2021-11-07 |
8 | | - |
9 | | -WORKDIR /$APP |
10 | | - |
11 | | -COPY . /$APP |
12 | | - |
13 | | -RUN apt-get update && \ |
14 | | - apt-get -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" dist-upgrade -y && \ |
15 | | - apt-get install -y cmake pkg-config libssl-dev git clang |
16 | | - |
17 | | -RUN curl https://sh.rustup.rs -sSf | sh -s -- -y && \ |
18 | | - export PATH=$PATH:$HOME/.cargo/bin && \ |
19 | | - rustup toolchain install $RUSTC_VERSION && \ |
20 | | - rustup target add wasm32-unknown-unknown --toolchain $RUSTC_VERSION && \ |
21 | | - cargo +$RUSTC_VERSION build --$PROFILE |
22 | | - |
23 | | -# ===== SECOND STAGE ====== |
24 | | - |
25 | | -FROM phusion/baseimage:0.11 |
26 | | -LABEL maintainer "xuliuchengxlc@gmail.com" |
27 | | -LABEL description="A very small image where we copy the ChainX binary created from the builder image." |
28 | | - |
29 | | -ARG PROFILE=release |
30 | | -ARG APP=chainx |
31 | | - |
32 | | -COPY --from=builder /$APP/target/$PROFILE/$APP /usr/local/bin |
33 | | - |
34 | | -RUN mv /usr/share/ca* /tmp && \ |
35 | | - rm -rf /usr/share/* && \ |
36 | | - mv /tmp/ca-certificates /usr/share/ && \ |
37 | | - rm -rf /usr/lib/python* && \ |
38 | | - mkdir -p /root/.local/share/chainx && \ |
39 | | - ln -s /root/.local/share/chainx /data |
40 | | - |
41 | | -RUN rm -rf /usr/bin /usr/sbin |
42 | | - |
43 | | -EXPOSE 20222 8086 8087 9615 |
44 | | - |
| 1 | +# This is the build stage for ChainX. Here we create the binary. |
| 2 | +FROM docker.io/paritytech/ci-linux:production as builder |
| 3 | + |
| 4 | +WORKDIR /chainx |
| 5 | +COPY . /chainx |
| 6 | +RUN cargo build --locked --release |
| 7 | + |
| 8 | +# This is the 2nd stage: a very small image where we copy the ChainX binary." |
| 9 | +FROM docker.io/library/ubuntu:20.04 |
| 10 | + |
| 11 | +COPY --from=builder /chainx/target/release/chainx /usr/local/bin |
| 12 | + |
| 13 | +RUN useradd -m -u 1000 -U -s /bin/sh -d /chainx chainx && \ |
| 14 | + mkdir -p /data /chainx/.local/share/chainx && \ |
| 15 | + chown -R chainx:chainx /data && \ |
| 16 | + ln -s /data /chainx/.local/share/chainx && \ |
| 17 | +# unclutter and minimize the attack surface |
| 18 | + rm -rf /usr/bin /usr/sbin && \ |
| 19 | +# Sanity checks |
| 20 | + ldd /usr/local/bin/chainx && \ |
| 21 | + /usr/local/bin/chainx --version |
| 22 | + |
| 23 | +USER chainx |
| 24 | +EXPOSE 30333 9933 9944 9615 |
45 | 25 | VOLUME ["/data"] |
46 | 26 |
|
47 | 27 | CMD ["/usr/local/bin/chainx"] |
0 commit comments