This repository was archived by the owner on Nov 15, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Improve docker image size with a 2 stages image #463
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
a1aa87b
Improve docker image size with a 2 stages image
ed28db1
Merge branch 'master' into will-docker-stages
chevdor 08414ed
Minor doc updates
c73cee3
Fix and reduce size of the docker image
5721984
Fix paths in scripts
ce9ffba
Merge branch 'master' of https://github.com/paritytech/polkadot into …
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 "[email protected]" | ||
| 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 "[email protected]" | ||
| 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this can be changed to
mv /usr/share/ca-certificates /tmp, since you only move backca-certificates2 lines below.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes indeed, same effect, I have been lazy on that one :)