Repository navigation
fix: restore standalone image optimization with correct runtime ownership - #12
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Image optimization fails in the deployed standalone image for two independent reasons:
sharpis absent from the application dependencies and runtime image; settingNEXT_SHARP_PATHdoes not install it.nextjsUID/GID 1001./app/.nextis owned by 1001:1001 with mode 0755, so UID 1000 cannot create the missing.next/cachedirectory.Add
sharp0.35.5 and build the standalone output inside Node 24.22.1 Alpine, matching the runtime architecture/libc and native image libraries. Use the existing non-rootnodeuser (1000:1000), copy runtime files with matching ownership, and explicitly create the writable cache. No world-writable permissions or GitOps changes are required.Add a real container regression that runs with
--network none --user 1000:1000. It serves an existing local PNG through/_next/image, decodes the 64px WebP using the container's own sharp, verifies MISS→HIT, verifies cache-file ownership, restarts the container, and requires a persisted disk-cache HIT. The existing workflow loads and tests the complete image before its main-only publication step. Pull requests do not log into the registry, push images, or deploy.Validation:
npm ci --no-audit --no-fund,npm test -- --runInBand(4 suites / 32 tests),npm run build.node --check scripts/test-standalone-image.mjs, actionlint,git diff --check, staged gitleaks scan.a55ad4f833f0a8d174fed18374d4e2a2e72a2ce1: complete Alpine image build plus real container image regression, Node 24.22.1, sharp 0.35.5/libvips 8.18.7, 64×15 WebP decoded to 3840 pixel bytes, cold MISS→HIT and persisted HIT after restart. Registry login and publication were skipped.sha256:f0b9b455217c16c924306f077d43a4283c2c8a7eb57f7d772415a740b9b4e89c.No production writes, merge, or deployment were performed.