fix(docker): npm install statt npm ci fuer sharp-Prebuilts
Some checks failed
Build & Publish Docker Image / build-and-push (push) Failing after 48s
Some checks failed
Build & Publish Docker Image / build-and-push (push) Failing after 48s
Der vorige Fix (ignore-scripts + rebuild, plus Fresh-ci im Builder) hat den sharp-Prebuilt trotzdem nicht installiert. Ursache: der Windows- generierte Lockfile markiert @img/sharp-linuxmusl-arm64 als "dev": true, sodass npm ci die Prebuilt-Binary konsistent auslaesst — egal ob mit --include=optional. npm install dagegen resolvt Optional-Deps frisch fuer die Build-Plattform (linux-arm64-musl im Docker) und findet die Prebuilts. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
25
Dockerfile
25
Dockerfile
@@ -8,26 +8,21 @@ WORKDIR /app
|
||||
RUN apk add --no-cache python3 make g++ libc6-compat vips-dev
|
||||
|
||||
COPY package*.json ./
|
||||
# --ignore-scripts vermeidet eine Race-Condition: sharp's postinstall checkt,
|
||||
# ob seine Plattform-Prebuilt-Binary (@img/sharp-linuxmusl-arm64) schon im
|
||||
# node_modules liegt. Bei parallelem Install ist sie das mitunter nicht, und
|
||||
# sharp fällt auf "build from source" zurück — das scheitert, weil wir
|
||||
# node-addon-api nicht haben. Mit --ignore-scripts + npm rebuild danach
|
||||
# sind alle Deps garantiert fertig installiert, bevor postinstall läuft.
|
||||
RUN npm ci --ignore-scripts --include=optional
|
||||
RUN npm rebuild
|
||||
# Bewusst npm install (nicht npm ci): der package-lock.json wird auf dem
|
||||
# Dev-System (Windows) generiert und markiert die linux-musl-arm64-Prebuilts
|
||||
# von sharp als "dev": true, sodass npm ci sie nicht installiert. npm install
|
||||
# resolvt Optional-Deps frisch fuer die aktuelle Plattform (= linux-arm64-musl
|
||||
# im Docker-Build) und findet die Prebuilts korrekt. Die package.json-semver-
|
||||
# Ranges sorgen fuer hinreichende Reproduzierbarkeit.
|
||||
RUN npm install --include=optional --no-audit --no-fund
|
||||
|
||||
COPY . .
|
||||
RUN npm run build
|
||||
|
||||
# Clean re-install statt npm prune. Grund: package-lock.json wird auf dem Dev-
|
||||
# System (Windows) generiert, dabei markiert npm die linux-musl-arm64-Prebuilts
|
||||
# als "dev": true, obwohl sie für's Runtime gebraucht werden. npm prune --omit=dev
|
||||
# würde sie entfernen. Ein Fresh-Install mit --omit=dev installiert dagegen nur
|
||||
# das, was für's Runtime nötig ist, inkl. matchenden Prebuilts.
|
||||
# Fresh-Install fuer den Runtime-Stage: nur Produktions-Deps, wieder mit
|
||||
# npm install statt ci aus demselben Grund wie oben.
|
||||
RUN rm -rf node_modules \
|
||||
&& npm ci --ignore-scripts --omit=dev --include=optional \
|
||||
&& npm rebuild
|
||||
&& npm install --omit=dev --include=optional --no-audit --no-fund
|
||||
|
||||
FROM node:22-alpine AS runner
|
||||
WORKDIR /app
|
||||
|
||||
Reference in New Issue
Block a user