-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
eb67aa1
commit f806ce8
Showing
7 changed files
with
159 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
# Note: We don't use Alpine and its packaged Rust/Cargo because they're too often out of date, | ||
# preventing them from being used to build Substrate/Polkadot. | ||
|
||
FROM phusion/baseimage:0.11 as builder | ||
LABEL maintainer="[email protected]" | ||
LABEL description="This is the build stage for Substrate. Here we create the binary." | ||
|
||
ENV DEBIAN_FRONTEND=noninteractive | ||
|
||
ARG PROFILE=release | ||
WORKDIR /substrate | ||
|
||
COPY . /substrate | ||
|
||
RUN apt-get update && \ | ||
apt-get dist-upgrade -y -o Dpkg::Options::="--force-confold" && \ | ||
apt-get install -y cmake pkg-config libssl-dev git clang | ||
|
||
RUN curl https://sh.rustup.rs -sSf | sh -s -- -y && \ | ||
export PATH="$PATH:$HOME/.cargo/bin" && \ | ||
rustup install nightly-2020-10-01 && \ | ||
rustup target add wasm32-unknown-unknown --toolchain nightly-2020-10-01 && \ | ||
rustup default stable && \ | ||
cargo +nightly-2020-10-01 build "--$PROFILE" | ||
|
||
# ===== SECOND STAGE ====== | ||
|
||
FROM phusion/baseimage:0.11 | ||
LABEL maintainer="[email protected]" | ||
LABEL description="This is the 2nd stage: a very small image where we copy the Substrate binary." | ||
ARG PROFILE=release | ||
|
||
RUN mv /usr/share/ca* /tmp && \ | ||
rm -rf /usr/share/* && \ | ||
mv /tmp/ca-certificates /usr/share/ && \ | ||
useradd -m -u 1000 -U -s /bin/sh -d /substrate substrate && \ | ||
mkdir -p /substrate/.local/share/substrate && \ | ||
chown -R substrate:substrate /substrate/.local && \ | ||
ln -s /substrate/.local/share/substrate /data | ||
|
||
COPY --from=builder /substrate/target/$PROFILE/substrate /usr/local/bin | ||
|
||
# checks | ||
RUN ldd /usr/local/bin/substrate && \ | ||
/usr/local/bin/substrate --version | ||
|
||
# Shrinking | ||
RUN rm -rf /usr/lib/python* && \ | ||
rm -rf /usr/bin /usr/sbin /usr/share/man | ||
|
||
USER substrate | ||
EXPOSE 30333 9933 9944 9615 | ||
VOLUME ["/data"] | ||
|
||
CMD ["/usr/local/bin/substrate --ws-external"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
FROM debian:stretch-slim | ||
# show backtraces | ||
ENV RUST_BACKTRACE 1 | ||
|
||
# install tools and dependencies | ||
RUN apt-get update && \ | ||
DEBIAN_FRONTEND=noninteractive apt-get upgrade -y && \ | ||
DEBIAN_FRONTEND=noninteractive apt-get install -y \ | ||
libssl1.1 \ | ||
ca-certificates \ | ||
glibc \ | ||
curl && \ | ||
|
||
# apt cleanup | ||
apt-get autoremove -y && \ | ||
apt-get clean && \ | ||
find /var/lib/apt/lists/ -type f -not -name lock -delete; \ | ||
# add user | ||
useradd -m -u 1000 -U -s /bin/sh -d /node-template substrate | ||
|
||
# add substrate binary to docker image | ||
COPY ./node-template /usr/local/bin | ||
|
||
USER substrate | ||
|
||
# check if executable works in this container | ||
RUN /usr/local/bin/node-template --version | ||
|
||
EXPOSE 30333 9933 9944 | ||
VOLUME ["./node-template"] | ||
|
||
ENTRYPOINT ["/usr/local/bin/node-template --ws-external"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
FROM debian:stretch-slim | ||
# show backtraces | ||
ENV RUST_BACKTRACE 1 | ||
|
||
# install tools and dependencies | ||
RUN apt-get update && \ | ||
DEBIAN_FRONTEND=noninteractive apt-get upgrade -y && \ | ||
DEBIAN_FRONTEND=noninteractive apt-get install -y \ | ||
libssl1.1 \ | ||
ca-certificates \ | ||
curl && \ | ||
# apt cleanup | ||
apt-get autoremove -y && \ | ||
apt-get clean && \ | ||
find /var/lib/apt/lists/ -type f -not -name lock -delete; \ | ||
# add user | ||
useradd -m -u 1000 -U -s /bin/sh -d /node-template substrate | ||
|
||
# add substrate binary to docker image | ||
COPY ../target/release/node-template /usr/local/bin | ||
|
||
USER substrate | ||
|
||
# check if executable works in this container | ||
RUN /usr/local/bin/node-template --version | ||
|
||
EXPOSE 30333 9933 9944 | ||
VOLUME ["../target/release/node-template"] | ||
|
||
ENTRYPOINT ["/usr/local/bin/node-template --ws-external"] |