|
| 1 | +# Note: We don't use Alpine and its packaged Rust/Cargo because they're too often out of date, |
| 2 | +# preventing them from being used to build Substrate/Polkadot/Plug. |
| 3 | + |
| 4 | +FROM phusion/baseimage:0.11 as builder |
| 5 | +LABEL description="Pl^g build image: The Pl^g binary is built here." |
| 6 | + |
| 7 | +ENV DEBIAN_FRONTEND=noninteractive |
| 8 | + |
| 9 | +ARG PROFILE=release |
| 10 | +WORKDIR /plug |
| 11 | + |
| 12 | +COPY . /plug |
| 13 | + |
| 14 | +RUN apt-get update && \ |
| 15 | + apt-get dist-upgrade -y -o Dpkg::Options::="--force-confold" && \ |
| 16 | + apt-get install -y \ |
| 17 | + clang \ |
| 18 | + cmake \ |
| 19 | + git \ |
| 20 | + libssl-dev \ |
| 21 | + pkg-config |
| 22 | + |
| 23 | +RUN curl https://sh.rustup.rs -sSf | sh -s -- -y && \ |
| 24 | + export PATH="$PATH:$HOME/.cargo/bin" && \ |
| 25 | + .plug/bootstrap && \ |
| 26 | + cargo build "--$PROFILE" |
| 27 | + |
| 28 | +# ===== SECOND STAGE ====== |
| 29 | + |
| 30 | +FROM phusion/baseimage:0.11 |
| 31 | +LABEL description="Pl^g runner image: A minimal image for running Pl^g." |
| 32 | +ARG PROFILE=release |
| 33 | + |
| 34 | +RUN mv /usr/share/ca* /tmp && \ |
| 35 | + rm -rf /usr/share/* && \ |
| 36 | + mv /tmp/ca-certificates /usr/share/ && \ |
| 37 | + useradd -m -u 1000 -U -s /bin/sh -d /plug plug && \ |
| 38 | + mkdir -p /plug/.local/share/plug && \ |
| 39 | + chown -R plug:plug /plug/.local && \ |
| 40 | + ln -s /plug/.local/share/plug /data |
| 41 | + |
| 42 | +COPY --from=builder /plug/target/$PROFILE/plug /usr/local/bin |
| 43 | +COPY --from=builder /plug/target/$PROFILE/subkey /usr/local/bin |
| 44 | +COPY --from=builder /plug/target/$PROFILE/node-rpc-client /usr/local/bin |
| 45 | +COPY --from=builder /plug/target/$PROFILE/chain-spec-builder /usr/local/bin |
| 46 | + |
| 47 | +# checks |
| 48 | +RUN ldd /usr/local/bin/plug && \ |
| 49 | + /usr/local/bin/plug --version |
| 50 | + |
| 51 | +# Shrinking |
| 52 | +RUN rm -rf /usr/lib/python* && \ |
| 53 | + rm -rf /usr/bin /usr/sbin /usr/share/man |
| 54 | + |
| 55 | +USER plug |
| 56 | +EXPOSE 30333 9933 9944 9615 |
| 57 | +VOLUME ["/data"] |
| 58 | + |
| 59 | +ENTRYPOINT ["/usr/local/bin/plug"] |
0 commit comments