Skip to content

Optimize Docker image size with multi-stage build#79

Merged
chorrell merged 2 commits intomainfrom
optimize-image-size
Feb 10, 2026
Merged

Optimize Docker image size with multi-stage build#79
chorrell merged 2 commits intomainfrom
optimize-image-size

Conversation

@chorrell
Copy link
Owner

@chorrell chorrell commented Feb 9, 2026

Summary

This PR optimizes the Docker image size by implementing a multi-stage build that reduces the final image from 227MB to 187MB (~18% reduction).

Changes

  • Introduced multi-stage build with separate builder and runtime stages
  • Runtime stage uses minimal Alpine 3.23 base instead of node:lts-alpine
  • Copy only essential components to runtime:
    • Node binary
    • Required libraries (libstdc++.so.6, libgcc_s.so.1)
    • json package (no other node_modules)
  • Removed docker-entrypoint.sh wrapper (call Node directly)
  • Eliminated npm, yarn, and other unnecessary Node.js tooling

Testing

All functionality verified:

  • Version check: ✓
  • Grouping with -g: ✓
  • Itemizing with -a: ✓

Benefits

  • Smaller image size (187MB vs 227MB)
  • Faster pull/push times
  • Reduced attack surface (no package managers in runtime)
  • Same functionality and compatibility

chorrell and others added 2 commits February 9, 2026 18:00
Use multi-stage build with minimal Alpine base to reduce image size
from 227MB to 187MB. Copy only Node binary, required libraries, and
the json package to runtime stage, eliminating npm and unnecessary
Node.js tooling.

Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com>
These are no longer needed as the optimized image runs Node directly
without shell script wrappers.

Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com>
@chorrell chorrell merged commit 6c78582 into main Feb 10, 2026
2 checks passed
@chorrell chorrell deleted the optimize-image-size branch February 10, 2026 16:18
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