Skip to content

10x smaller Docker image #869

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

christopher-conley
Copy link

This PR would merge these 3 commits:

Dockerfile rewrite
Add build script to .dockerignore
Add build script because I forgot to in the previous commit

The Dockerfile rewrite commit contains the bulk of the changes. It now employs a 2-stage build process in which everything from the initial build stage is discarded except the build artifacts that matter, which are then brought forward into a new instance of the base image.

The various scripts (src.sh, ubuntu.sh, pip.sh, etc) are folded directly into the Dockerfile and are redundant for the purpose of building a Docker image if these commits are merged, but I left them intact since the Wiki looks like it makes reference to them for people building binwalk from scratch. The bulk of the content from the scripts are now within two individual RUN commands in the Dockerfile.

These changes result in a final docker image that builds faster, has fewer layers, and is ~10x smaller than the docker image produced when following the instructions on the wiki here.:

[cicd]@[BUILD-FJKXVM2][/tmp]# docker image ls
REPOSITORY                  TAG             IMAGE ID       CREATED              SIZE
binwalkv3                   latest          23bd5d10d6e7   55 minutes ago       3.61GB
binwalk-newimage            latest          ef2e01d454a0   About an hour ago    397MB

The rust compiler & toolchain, clang & friends, unnecessary build artifacts, apt cache, etc. are absent in the final image, which makes a dramatic difference in size vs. the instructions on the wiki to build a Docker image.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant