-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Improve docker image size with a 2 stages image #463
Conversation
Short update on the progress here: As it turns out, using the rust base image it not a good strategy as it results in a binary that misses libssl when using slim images.
The latest is much much smaller and has no known vulnerability. Failure with ubuntu:18.10 is:
|
The libssl issue is solvable with the following in the second stage when using
it results in a running polkadot but failing to connect to telemetry. |
After lots of testing here is the conclusion (I will also fix this PR). The best I got was:
dockerfile``` 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 COPY . /polkadot RUN apt-get update && RUN curl https://sh.rustup.rs -sSf | sh -s -- -y && ===== SECOND STAGE ======FROM phusion/baseimage:0.10.0 RUN mv /usr/share/ca* /tmp && RUN rm -rf /usr/bin /usr/sbin EXPOSE 30333 9933 9944 CMD ["/usr/local/bin/polkadot"]
|
96160d3
to
5721984
Compare
…will-docker-stages
ARG PROFILE=release | ||
COPY --from=builder /polkadot/target/$PROFILE/polkadot /usr/local/bin | ||
|
||
RUN mv /usr/share/ca* /tmp && \ |
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 back ca-certificates
2 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 :)
* Improve docker image size with a 2 stages image * Minor doc updates * Fix and reduce size of the docker image * Fix paths in scripts
* Use parity-ethereum rev 02c54d42398f to fix build * More lockfiles and new build artifacts * Update .gitlab-ci.yml (#633) it is necessary to test. You will probably have to create a cron-job for the nightly assembly of the master branch * Do not attempt to rustup if in CI. This is taken care of by the base (#621) image. * Improve docker image size with a 2 stages image (#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 * cargo --force to allow CI to build. (#599)
* ChainX TC0 * Update btc testnet header * Use Testnet in xpallet-system * Add ptc0 chain * Bump spec version to 7 * Fast governance processure * Add malan runtime * Add malan.json * Rename chainx-dev-runtime to dev-runtime * Use dns in bootnode * Fix clippy under runtime-benchmarks feature * Update error message for invalid chain option * Add two more malan bootnodes * Rebuild malan genesis config * Update btc genesis * Use new manlan config * Update malan.json * Use new malan.json * Rebuild malan runtime Since we currently has only one executor(`chainx`), we must use spec_name = "chainx" in the runtime code. * Update malan.json * Use malan.json * Clean up unused code * Revert chainx.json changes
Bump runtime version
This improves both build time and size of the docker image.
It also moves all the scripts under a
scripts
folder.In order to optimize the build time, I split the
build.sh
script into a production build and a-demo
one. This is however no longer used at all by the docker image building.@pepyakin please let me know whether you find the split interesting to keep, otherwise, I will revert that part. I made sure the demos are still part of the CI.