Skip to content
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

Switch to a slim debian Docker image [PLT-1610] #2521

Merged
merged 1 commit into from
Oct 10, 2023
Merged

Conversation

yob
Copy link
Contributor

@yob yob commented Oct 10, 2023

The slim image comes with far fewer packages pre-installed and we need to manually installed a handful that we need (like curl and build-essential), but in return we get:

  • A slightly smaller final image
  • Fewer debian packages installed, which means fewer (low value, noisy) CVEs will be detected

The resulting image size difference looks like this:

docs                      slim-bookworm                           b7b6f5d9d33a   3 days ago      1.35GB
docs                      bookwork                                8a6a4a888efe   3 days ago      1.84GB

I think we could probably get it a lot smaller via multistage build, by ensuring tools like nodejs, gh, svn, mercurial, make, gcc, and cpp are used to build assets and native extensions, but not included in the final image. Still, this is a good start.

/cc @danstn

The slim image comes with far fewer packages pre-installed and we need
to manually installed a handful that we need (like curl and
build-essential), but in return we get:

* A slightly smaller final image
* Fewer debian packages installed, which means fewer CVEs will be
  detected
@buildkite-docs-bot
Copy link
Contributor

Preview URL: https://2521--bk-docs-preview.netlify.app

# Install all the things
&& apt-get update \
&& apt-get install -y nodejs gh jq \
&& apt-get install -y nodejs gh jq build-essential \
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

build-essential is the main thing that was missing from slim. It's needed to compile and install various ruby/node native packages.

RUN echo "--- :package: Installing system deps" \
# Cache apt
rm -f /etc/apt/apt.conf.d/docker-clean \
&& echo 'Binary::apt::APT::Keep-Downloaded-Packages "true";' > /etc/apt/apt.conf.d/keep-cache \
# Install a few pre-reqs
&& apt-get update \
&& apt-get install -y curl gnupg \
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

curl and gnupg aren't needed in prod, but we do need them in the Dockerfile steps further down

@yob yob requested review from dannymidnight and a team October 10, 2023 04:27
@yob yob marked this pull request as ready for review October 10, 2023 04:30
@yob yob changed the title Switch to a slim debian Docker image Switch to a slim debian Docker image [PLT-1610] Oct 10, 2023
@dannymidnight
Copy link
Contributor

Nice. On a related note I'm still very much thinking about converting the docs into a static site with the intent to eventually remove this image from production. I imagine this image will still kick around for a while and continue being used in CI but not necessarily for serving traffic.

@yob yob merged commit fa8ae33 into main Oct 10, 2023
1 check passed
@yob yob deleted the debian-bookworm-slim branch October 10, 2023 05:00
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.

3 participants