[PR #735] [MERGED] fix(docker-lite): keep sharp installed in deps stage #4755

Closed
opened 2026-10-22 04:10:22 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/735
Author: @Romuromylus
Created: 5/12/2026
Status: ✅ Merged
Merged: 5/12/2026
Merged by: @Romuromylus

Base: main ← Head: fix/sharp-required-not-optional


📝 Commits (1)

  • d6b35ac fix(docker-lite): keep sharp installed in deps stage

📊 Changes

3 files changed (+18 additions, -7 deletions)

View changed files

📝 Dockerfile.lite (+12 -2)
📝 packages/server/package.json (+2 -2)
📝 pnpm-lock.yaml (+4 -3)

📄 Description

Linked issue

Closes #734

Why this change

  • Building Dockerfile.lite produces an image that crashes immediately on startup with ERR_MODULE_NOT_FOUND: Cannot find package 'sharp' imported from /app/packages/server/dist/routes/game-assets.routes.js.
  • Sharp is declared in packages/server/package.json's optionalDependencies, but packages/server/src/routes/game-assets.routes.ts uses a static import sharp from "sharp" at module load. The Lite deps stage installs with --no-optional, drops sharp, and the static import kills the process before the server can serve a request.
  • Reported on Debian 12 LXC, Intel J5005 (CPU-only) — see #734 by @Gunterlie.

What changed

  • packages/server/package.json: moved sharp from optionalDependencies to dependencies. Sharp is genuinely required (game-assets routes, sprite generation, background removal). Only onnxruntime-node and onnxruntime-web remain in optionalDependencies — those are the truly-optional Lite-mode skippables.
  • Dockerfile.lite deps stage: cannot keep --no-optional because sharp's native binary ships through transitive optional packages (@img/sharp-linux-x64), which pnpm --no-optional drops alongside the genuinely-optional onnxruntime packages. New flow:
    1. pnpm install --frozen-lockfile --prod --ignore-scripts (no --no-optional)
    2. pnpm rebuild sharp to register the native binding that --ignore-scripts skipped at install time
    3. rm -rf onnxruntime-node / onnxruntime-web from the .pnpm store and the per-workspace symlinks, so the Lite image stays small
  • pnpm-lock.yaml: regenerated to reflect sharp's new section under packages/server's dependencies. No other changes.

The regular Dockerfile already installs with pnpm install --frozen-lockfile --prod (no --no-optional), so the package-manifest move is backward-compatible there — no change in behavior for the full image.

Validation

  • pnpm check passes locally
  • Container (Docker / Podman) built and ran without issue
  • Ran the app, clicked through the changes manually
  • Checked edge cases (light + dark mode, mobile viewport, empty states, error paths)
  • Above manual verification completed (describe below)
  • Read and followed CONTRIBUTING.md

Manual verification notes

Build + smoke test performed on a fresh amd64 Linux host (Ubuntu 5.15, Docker 28.4):

docker build --no-cache -f Dockerfile.lite -t marinara-test:lite .
docker run -d --name marinara-smoke -p 17860:7860 marinara-test:lite

Observed:

  • Container reaches running state, exit code 0, no restarts.
  • Endpoint GET http://127.0.0.1:17860/ returns HTTP 200 (no startup crash — sharp's static import resolves successfully).
  • Inside the container: sharp v0.34.5 / libvips v8.17.3 loads cleanly, and a 10×10 PNG roundtrip via sharp({create:...}).png().toBuffer() succeeds (proves the native binding is registered, not just discoverable on disk).
  • onnxruntime-node and onnxruntime-web are absent from both /app/node_modules/.pnpm and /app/packages/server/node_modules (pruning works).
  • Final image size: 774 MB (comparable to the previous Lite size; onnxruntime stays out).

Still needs human verification:

  • Manually verify in the original reporter's environment (Debian 12 LXC, J5005 CPU-only) that the rebuild + prune flow works on a constrained host.
  • Manually exercise sprite generation and background removal end-to-end in a running Lite container.
  • Manually verify the full (non-Lite) Dockerfile still builds and runs unchanged (the package-manifest move is intended to be a no-op there, but worth confirming).

Docs and release impact

  • No docs changes needed
  • Updated docs (README / CONTRIBUTING / android/README / CHANGELOG) as needed
  • Version/release files updated (only if this PR includes a version bump)

UI evidence (if applicable)

N/A — Docker build + server startup fix, no UI surface affected.

Summary by CodeRabbit

  • Chores
    • Optimized the Lite Docker image to reduce its overall size through refined dependency installation and selective package removal during the build process.
    • Updated package dependency management to make the sharp library a required dependency instead of an optional one.

Review Change Stack


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/Pasta-Devs/Marinara-Engine/pull/735 **Author:** [@Romuromylus](https://github.com/Romuromylus) **Created:** 5/12/2026 **Status:** ✅ Merged **Merged:** 5/12/2026 **Merged by:** [@Romuromylus](https://github.com/Romuromylus) **Base:** `main` ← **Head:** `fix/sharp-required-not-optional` --- ### 📝 Commits (1) - [`d6b35ac`](https://github.com/Pasta-Devs/Marinara-Engine/commit/d6b35acbcf5f1ad0f64fdad97db83044f2d56613) fix(docker-lite): keep sharp installed in deps stage ### 📊 Changes **3 files changed** (+18 additions, -7 deletions) <details> <summary>View changed files</summary> 📝 `Dockerfile.lite` (+12 -2) 📝 `packages/server/package.json` (+2 -2) 📝 `pnpm-lock.yaml` (+4 -3) </details> ### 📄 Description ## Linked issue Closes #734 ## Why this change - Building `Dockerfile.lite` produces an image that crashes immediately on startup with `ERR_MODULE_NOT_FOUND: Cannot find package 'sharp' imported from /app/packages/server/dist/routes/game-assets.routes.js`. - Sharp is declared in `packages/server/package.json`'s `optionalDependencies`, but `packages/server/src/routes/game-assets.routes.ts` uses a static `import sharp from "sharp"` at module load. The Lite deps stage installs with `--no-optional`, drops sharp, and the static import kills the process before the server can serve a request. - Reported on Debian 12 LXC, Intel J5005 (CPU-only) — see #734 by @Gunterlie. ## What changed - `packages/server/package.json`: moved `sharp` from `optionalDependencies` to `dependencies`. Sharp is genuinely required (game-assets routes, sprite generation, background removal). Only `onnxruntime-node` and `onnxruntime-web` remain in `optionalDependencies` — those are the truly-optional Lite-mode skippables. - `Dockerfile.lite` deps stage: cannot keep `--no-optional` because sharp's native binary ships through transitive optional packages (`@img/sharp-linux-x64`), which pnpm `--no-optional` drops alongside the genuinely-optional onnxruntime packages. New flow: 1. `pnpm install --frozen-lockfile --prod --ignore-scripts` (no `--no-optional`) 2. `pnpm rebuild sharp` to register the native binding that `--ignore-scripts` skipped at install time 3. `rm -rf` `onnxruntime-node` / `onnxruntime-web` from the `.pnpm` store and the per-workspace symlinks, so the Lite image stays small - `pnpm-lock.yaml`: regenerated to reflect sharp's new section under `packages/server`'s `dependencies`. No other changes. The regular `Dockerfile` already installs with `pnpm install --frozen-lockfile --prod` (no `--no-optional`), so the package-manifest move is backward-compatible there — no change in behavior for the full image. ## Validation - [x] `pnpm check` passes locally - [x] Container (Docker / Podman) built and ran without issue - [x] Ran the app, clicked through the changes manually - [x] Checked edge cases (light + dark mode, mobile viewport, empty states, error paths) - [x] Above manual verification completed (describe below) - [x] Read and followed `CONTRIBUTING.md` ### Manual verification notes Build + smoke test performed on a fresh amd64 Linux host (Ubuntu 5.15, Docker 28.4): ```bash docker build --no-cache -f Dockerfile.lite -t marinara-test:lite . docker run -d --name marinara-smoke -p 17860:7860 marinara-test:lite ``` Observed: - Container reaches `running` state, exit code 0, no restarts. - Endpoint `GET http://127.0.0.1:17860/` returns HTTP 200 (no startup crash — sharp's static import resolves successfully). - Inside the container: `sharp v0.34.5 / libvips v8.17.3` loads cleanly, and a 10×10 PNG roundtrip via `sharp({create:...}).png().toBuffer()` succeeds (proves the native binding is registered, not just discoverable on disk). - `onnxruntime-node` and `onnxruntime-web` are absent from both `/app/node_modules/.pnpm` and `/app/packages/server/node_modules` (pruning works). - Final image size: 774 MB (comparable to the previous Lite size; onnxruntime stays out). Still needs human verification: - Manually verify in the original reporter's environment (Debian 12 LXC, J5005 CPU-only) that the rebuild + prune flow works on a constrained host. - Manually exercise sprite generation and background removal end-to-end in a running Lite container. - Manually verify the full (non-Lite) `Dockerfile` still builds and runs unchanged (the package-manifest move is intended to be a no-op there, but worth confirming). ## Docs and release impact - [x] No docs changes needed - [ ] Updated docs (README / CONTRIBUTING / android/README / CHANGELOG) as needed - [ ] Version/release files updated (only if this PR includes a version bump) ## UI evidence (if applicable) N/A — Docker build + server startup fix, no UI surface affected. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Chores** * Optimized the Lite Docker image to reduce its overall size through refined dependency installation and selective package removal during the build process. * Updated package dependency management to make the sharp library a required dependency instead of an optional one. [![Review Change Stack](https://storage.googleapis.com/coderabbit_public_assets/review-stack-in-coderabbit-ui.svg)](https://app.coderabbit.ai/change-stack/Pasta-Devs/Marinara-Engine/pull/735) <!-- end of auto-generated comment: release notes by coderabbit.ai --> --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-22 04:10:22 +07:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Pasta-Devs/Marinara-Engine#4755
No description provided.