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

Shrink docker image from 1.64GB -> 740MB #213

Open
wants to merge 19 commits into
base: main
Choose a base branch
from

Conversation

rmlearney-digicatapult
Copy link
Contributor

@rmlearney-digicatapult rmlearney-digicatapult commented Nov 16, 2024

Pull Request

Checklist

  • Have you read Digital Catapult's Code of Conduct?
  • I have performed a self-review of my own code.
  • I have commented my code, particularly in hard-to-understand areas.
  • I have made corresponding changes to the documentation.
  • My changes generate no new warnings.
  • I have added tests that prove my fix is effective or that my feature works.
  • New and existing unit tests pass locally with my changes.

PR Type

Please delete options that are irrelevant.

  • Chore

Linked tickets

High level description

Change docker build process and underlying image to shrink final production image to 734MB

Detailed description

Rebased final image on node:lts-bookworm-slim with curl and openssl installed and cache cleaned
Using dive discovered that npm prune --omit=dev leaves a lot of unnecessary cache, so moved this to separate build stage and copied node_modules into final production image

Some other minor changes

This is nearing the theoretical limit for a docker image size for this project:
node 120MB
node_modules 448MB
/www 2MB

Describe alternatives you've considered

Operational impact

Additional context

@rmlearney-digicatapult rmlearney-digicatapult requested a review from a team as a code owner November 16, 2024 13:23
@rmlearney-digicatapult rmlearney-digicatapult changed the title Shrink docker image from 1.64GB -> 730MB Shrink docker image from 1.64GB -> 660MB Nov 17, 2024
@rmlearney-digicatapult rmlearney-digicatapult changed the title Shrink docker image from 1.64GB -> 660MB Shrink docker image from 1.64GB -> 740MB Nov 17, 2024
@rmlearney-digicatapult
Copy link
Contributor Author

It is possible to reduce the image size further to 660MB by using RedHat UBI9-minimal as the base image for the production layer, but I reverted these changes because it's not a distro we've used before.

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