nightscout-librelink-up
nightscout-librelink-up copied to clipboard
Reduce docker image size
This PR reduces the Docker image size massively while remaining on Debian Bookworm, as far as I can tell there should be no ill effects. Below are my comparisons.
Each step was rebuilt to ease comparison with:
docker build -t librelink-up-pr .
And they include the changes from previous steps.
Sizes are compared with:
docker image ls | grep librelink | awk '{print $NF,$1}'
Also a .dockerignore
file is included to avoid copying the git-related files and directories into the image.
Starting point
1.51GB librelink-up-pr
1.51GB timoschlueter/nightscout-librelink-up
Switch to node:20-bookworm-slim as base image
618MB librelink-up-pr
1.51GB timoschlueter/nightscout-librelink-up
Use a separate builder stage
277MB librelink-up-pr
1.51GB timoschlueter/nightscout-librelink-up
Remove devDependencies
This also involves pre-compiling the TypeScript code, I've changed the CMD
to reuse start-heroku
204MB librelink-up-pr
1.51GB timoschlueter/nightscout-librelink-up
Compressed size difference
For additional context:
$ docker save librelink-up-pr | gzip -c | pv -b >/dev/null
67,7MiB
$ docker save timoschlueter/nightscout-librelink-up | gzip -c | pv -b >/dev/null
448MiB