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.
Improve docker image size with a 2 stages image (paritytech#463)
* Improve docker image size with a 2 stages image * Minor doc updates * Fix and reduce size of the docker image * Fix paths in scripts
- Loading branch information
Showing
13 changed files
with
96 additions
and
70 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 |
---|---|---|
@@ -0,0 +1,2 @@ | ||
doc | ||
target |
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,38 @@ | ||
FROM phusion/baseimage:0.10.1 as builder | ||
LABEL maintainer "chevdor@gmail.com" | ||
LABEL description="This is the build stage for Polkadot. Here we create the binary." | ||
|
||
ARG PROFILE=release | ||
WORKDIR /polkadot | ||
|
||
COPY . /polkadot | ||
|
||
RUN apt-get update && \ | ||
apt-get upgrade -y && \ | ||
apt-get install -y cmake pkg-config libssl-dev git | ||
|
||
RUN curl https://sh.rustup.rs -sSf | sh -s -- -y && \ | ||
export PATH=$PATH:$HOME/.cargo/bin && \ | ||
cargo build --$PROFILE | ||
|
||
# ===== SECOND STAGE ====== | ||
|
||
FROM phusion/baseimage:0.10.0 | ||
LABEL maintainer "chevdor@gmail.com" | ||
LABEL description="This is the 2nd stage: a very small image where we copy the Polkadot binary." | ||
ARG PROFILE=release | ||
COPY --from=builder /polkadot/target/$PROFILE/polkadot /usr/local/bin | ||
|
||
RUN mv /usr/share/ca* /tmp && \ | ||
rm -rf /usr/share/* && \ | ||
mv /tmp/ca-certificates /usr/share/ && \ | ||
rm -rf /usr/lib/python* && \ | ||
mkdir -p /root/.local/share/Polkadot && \ | ||
ln -s /root/.local/share/Polkadot /data | ||
|
||
RUN rm -rf /usr/bin /usr/sbin | ||
|
||
EXPOSE 30333 9933 9944 | ||
VOLUME ["/data"] | ||
|
||
CMD ["/usr/local/bin/polkadot"] |
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
This file was deleted.
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 |
---|---|---|
@@ -1,18 +1,26 @@ | ||
#!/usr/bin/env bash | ||
set -e | ||
|
||
pushd . | ||
|
||
# The following line ensure we run from the project root | ||
PROJECT_ROOT=`git rev-parse --show-toplevel` | ||
cd $PROJECT_ROOT | ||
|
||
# Find the current version from Cargo.toml | ||
VERSION=`grep "^version" ../Cargo.toml | egrep -o "([0-9\.]+)"` | ||
VERSION=`grep "^version" ./Cargo.toml | egrep -o "([0-9\.]+)"` | ||
GITUSER=chevdor | ||
GITREPO=polkadot | ||
|
||
# Build the image | ||
echo "Building ${GITREPO}:$VERSION docker image, hang on!" | ||
time docker build --build-arg PROFILE=release -t ${GITUSER}/${GITREPO}:$VERSION . | ||
echo "Building ${GITUSER}/${GITREPO}:latest docker image, hang on!" | ||
time docker build -f ./docker/Dockerfile --build-arg PROFILE=release -t ${GITUSER}/${GITREPO}:latest . | ||
|
||
# Show the list of available images for this repo | ||
echo "Image is ready" | ||
docker images | grep ${GITREPO} | ||
|
||
echo -e "\nIf you just built the latest, you may want to update your tag:" | ||
echo " $ docker tag ${GITUSER}/${GITREPO}:$VERSION ${GITUSER}/${GITREPO}:latest" | ||
echo -e "\nIf you just built version ${VERSION}, you may want to update your tag:" | ||
echo " $ docker tag ${GITUSER}/${GITREPO}:$VERSION ${GITUSER}/${GITREPO}:${VERSION}" | ||
|
||
popd |
This file was deleted.
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
This file was deleted.
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,28 @@ | ||
#!/usr/bin/env bash | ||
|
||
# This script assumes that all pre-requisites are installed. | ||
|
||
set -e | ||
|
||
PROJECT_ROOT=`git rev-parse --show-toplevel` | ||
source `dirname "$0"`/common.sh | ||
|
||
export CARGO_INCREMENTAL=0 | ||
|
||
# Save current directory. | ||
pushd . | ||
|
||
cd $ROOT | ||
|
||
for DEMO in "${DEMOS[@]}" | ||
do | ||
echo "*** Building wasm binaries in $DEMO" | ||
cd "$PROJECT_ROOT/$DEMO" | ||
|
||
./build.sh | ||
|
||
cd - >> /dev/null | ||
done | ||
|
||
# Restore initial directory. | ||
popd |
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
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