forked from paritytech/substrate
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Revert from alpine to phusion and include wasm build (paritytech#2482)
* Revert from alpine to phusion and include wasm build * Update Dockerfile
- Loading branch information
Showing
2 changed files
with
34 additions
and
17 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
doc | ||
target | ||
**target* | ||
.idea/ | ||
Dockerfile | ||
.dockerignore |
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 |
---|---|---|
@@ -1,38 +1,55 @@ | ||
FROM alpine:edge AS builder | ||
# 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.10.2 as builder | ||
LABEL maintainer="chevdor@gmail.com" | ||
LABEL description="This is the build stage for Substrate. Here we create the binary." | ||
|
||
RUN apk add build-base \ | ||
cmake \ | ||
linux-headers \ | ||
openssl-dev \ | ||
clang-dev \ | ||
cargo | ||
|
||
ARG PROFILE=release | ||
WORKDIR /substrate | ||
|
||
COPY . /substrate | ||
|
||
RUN cargo build --$PROFILE | ||
RUN apt-get update && \ | ||
apt-get upgrade -y && \ | ||
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 toolchain install nightly && \ | ||
rustup target add wasm32-unknown-unknown --toolchain nightly && \ | ||
cargo install --git https://github.com/alexcrichton/wasm-gc && \ | ||
rustup default nightly && \ | ||
./scripts/build.sh && \ | ||
rustup default stable && \ | ||
cargo build --$PROFILE | ||
|
||
# ===== SECOND STAGE ====== | ||
|
||
FROM alpine:edge | ||
FROM phusion/baseimage:0.10.2 | ||
LABEL maintainer="chevdor@gmail.com" | ||
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/ && \ | ||
mkdir -p /root/.local/share/Polkadot && \ | ||
ln -s /root/.local/share/Polkadot /data && \ | ||
useradd -m -u 1000 -U -s /bin/sh -d /substrate substrate | ||
|
||
COPY --from=builder /substrate/target/$PROFILE/substrate /usr/local/bin | ||
|
||
RUN apk add --no-cache ca-certificates \ | ||
libstdc++ \ | ||
openssl | ||
# checks | ||
RUN ldd /usr/local/bin/substrate && \ | ||
/usr/local/bin/substrate --version | ||
|
||
# Shrinking | ||
RUN rm -rf /usr/lib/python* && \ | ||
mkdir -p /root/.local/share/Substrate && \ | ||
ln -s /root/.local/share/Substrate /data | ||
rm -rf /usr/bin /usr/sbin /usr/share/man | ||
|
||
USER substrate | ||
EXPOSE 30333 9933 9944 | ||
VOLUME ["/data"] | ||
|
||
ENTRYPOINT ["/usr/local/bin/substrate"] | ||
CMD ["/usr/local/bin/substrate"] |