feat: use binary in slim docker image #13
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Changes
Research
Did a quick research to compare running the application using Bun, as a binary on Debian and as a binary on Alpine. Here are the results:
Option: run typescript files on the offical bun image, running
bun server.js
Build command
Production image (simplified)
Size: 232MB (OS = 213MB, application = 3MB (of which source map 2MB), node modules 16MB
Coldstart bootstrap: 982ms
Option: binary on
debian:buster-slim
imageBuild command
production image
Size: 169MB
Coldstart bootstrap: 991ms
Option: binary on
alpine
Executable didn't work because it's built on
bitnami/node
, which uses debian.Size: 107MB (OS = 5MB, Binary = 102MB (of which Sourcemap is 2MB))
Tried fixes:
apk add gcompat
different error: Error relocating /app/server: unsupported relocation type 37apk add libc6-compat
different error: Error relocating /app/server: unsupported relocation type 37Both of those seem to cryptically indicate that you're missing shared libs or other files
Sources used:
Conclusion:
Checklist
code of conduct