Skip to content

Improve: smaller image and one nginx worker - #549

Merged
SandObserver merged 2 commits into
mainfrom
perf/slim-image-one-nginx-worker
Oct 24, 2026
Merged

SandObserver merged 2 commits into
mainfrom
perf/slim-image-one-nginx-worker

Conversation

@SandObserver

@SandObserver SandObserver commented Oct 24, 2026 •

Copy link
Copy Markdown
Owner

Summary

  • Name the runtime stage base, then copy it into a FROM scratch stage with COPY --from=base / / so the deleted npm, yarn, corepack and C headers no longer ship in a lower layer. The image is about 24 MB smaller on disk and about 7 MB smaller compressed, on amd64 and arm64.
  • Also remove /usr/local/include/node from the runtime image, and fail the build if node.h is still anywhere in it.
  • Reset every directory time in the base stage to the node binary's time, so the copied layer is identical for one base digest and updates reuse it.
  • Set nginx worker_processes 1 instead of auto with sed, and fail the build with grep -qx if the line does not apply. auto starts one worker per host core and ignores container CPU limits.
  • NODE_VERSION and YARN_VERSION are no longer set in the image. Nothing reads them.
  • Update the Dockerfile shape tests for the new stages. The runtime-content tests check every shipped stage, not only the last.

Testing
All green, including the Docker build and image scan. Added 2 tests for the nginx worker setting and the reproducible base layer.

Changelog

Changed

  • Shrink the image by about 24 MB and run one nginx worker instead of one per CPU core.

Checklist

  • Stays within the project constraints: one container, no runtime dependencies, no build step (see CONTRIBUTING.md).
  • Tests added or updated for new logic, and the full suite, lint, and typechecks pass.
  • Docs updated if behavior or configuration changed.

- Copy the cleaned Node base into a scratch stage so the removed npm, yarn,
  corepack and C headers no longer ship in a lower layer (about 24 MB smaller).
- Remove /usr/local/include/node from the runtime image.
- Set nginx worker_processes to 1 instead of one worker per host core.
- Update the Dockerfile shape tests for the new stages.
@SandObserver SandObserver added the docker Pull requests that update docker code label Oct 24, 2026
Reset every directory time in the base stage to the node binary's time, so
COPY --from=base produces the same layer for one base digest and updates
reuse it. Fail the build if node.h is still anywhere in the image. Check
every shipped stage, not only the last, in the runtime-content tests.
@SandObserver
SandObserver merged commit d96e1ef into main Oct 24, 2026
8 checks passed
@SandObserver
SandObserver deleted the perf/slim-image-one-nginx-worker branch October 24, 2026 05:36
stackyard-release Bot pushed a commit that referenced this pull request Oct 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docker Pull requests that update docker code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant