build/contrib: Improve docker support. #2740
Merged
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.
This significantly reworks the docker support to provide build a lightweight non-root distroless container image based on scratch. It employs a multi-stage build that downloads and builds the latest source code, compresses the resulting binaries, and then produces the final image based on scratch that only includes the Decred-specific binaries.
It must be noted that there are some still remaining TODO items in the documentation as well as the
Dockerfile
that will need to be handled by a future commit, but the changes are being submitted now to serve as a solid base for another contributor to finish up those aspects.The new final image is only 10.2MB as compared to the existing version which is nearly 1GB.
The following is an overview of the changes:
Dockerfile
andDockerfile.alpine
Dockerfile
undercontrib/docker
with the following properties:scratch
image (aka completely empty) and only includes the Decred-specific binaries which means there is no shell or any other binaries available if an attacker were to somehow manage to find a remote execution vulnerability exploit in a Decred binaryentrypoint
for the image since it is based onscratch
and thus has no shell for that purposecontrib/docker/README.md
README.md
in the main directory to account for changescontrib/README.md
to call out the new additionThis is work towards #2737.