Skip to content

feat: Updated node from 20 to 22, minimized docker image size through multiple build stages and switching from Debian to Alpine#3

Open
DieEneSchrodinger wants to merge 1 commit intotomtomwillis:mainfrom
DieEneSchrodinger:main
Open

feat: Updated node from 20 to 22, minimized docker image size through multiple build stages and switching from Debian to Alpine#3
DieEneSchrodinger wants to merge 1 commit intotomtomwillis:mainfrom
DieEneSchrodinger:main

Conversation

@DieEneSchrodinger
Copy link

@DieEneSchrodinger DieEneSchrodinger commented Mar 24, 2026

After looking into this project because I found the image size quite massive, I also found out it was still using node 20.
Node 20 is going EOL in the end of April 2026, and because of that should be updated.

This pull request changes a couple things:

  1. The Node version is updated from 20 to 22, which gives it another year of support. Node 24 wasn't chosen since it makes the better-sqlite3 rebuild fail.
  2. The build was made multi stage to keep all build dependencies out of the final image.
  3. The build now uses Alpine as a base rather than than Debian to make the image much smaller.
  4. The default user and group in the docker compose are now both 1000.
  5. The database in the docker compose is now in its own named volume.

The changes to the Dockerfile have the following effects on build time and on disk size of the image:

Image: On disk size: Docker build time: Node version:
Original (Debian) 2.73GB 69.7s 20
Original (Debian) 2.86GB 98.7s 22
Minimized(Debian) 1.65GB 123.1s 22
Minimized(Alpine) 769MB 101.4s 22

The additional time required to build the images mostly comes from having to recompile the better-sqlite3 module on Node 22, which adds around 50 seconds to the build time.

The changes to the compose file were made to align it with the standards defined in the Dockerfile in terms of the user and group id. The volume was made to require less user input when setting up the container.

During my testing of the image I found that everything still works just like the original image.

… multiple build stages and switching from Debian to Alpine
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