fix(docker): node-addon-api + ignore-scripts/rebuild fuer sharp
Some checks failed
Build & Publish Docker Image / build-and-push (push) Failing after 51s
Some checks failed
Build & Publish Docker Image / build-and-push (push) Failing after 51s
Drei Schichten Absicherung gegen den arm64-Build-Fehler: - --ignore-scripts beim npm install verhindert, dass sharp's postinstall check.js laeuft, bevor das @img/sharp-linuxmusl-arm64-Paket entpackt ist (Race in parallelem Install). - npm rebuild danach: alle Deps sind jetzt auf Disk, Postinstalls laufen sauber in Dependency-Reihenfolge. - node-addon-api als Runtime-Dep: falls die Prebuilt-Binary im npm-Tree nicht landet, kann sharp from-source bauen (vips-dev + python3 + make + g++ sind im Dockerfile bereits installiert). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
24
Dockerfile
24
Dockerfile
@@ -8,21 +8,25 @@ WORKDIR /app
|
|||||||
RUN apk add --no-cache python3 make g++ libc6-compat vips-dev
|
RUN apk add --no-cache python3 make g++ libc6-compat vips-dev
|
||||||
|
|
||||||
COPY package*.json ./
|
COPY package*.json ./
|
||||||
# Bewusst npm install (nicht npm ci): der package-lock.json wird auf dem
|
# Zwei Fallstricke werden hier adressiert:
|
||||||
# Dev-System (Windows) generiert und markiert die linux-musl-arm64-Prebuilts
|
# (a) Der auf Windows erzeugte package-lock.json markiert die linux-musl-
|
||||||
# von sharp als "dev": true, sodass npm ci sie nicht installiert. npm install
|
# arm64-Prebuilts von sharp als "dev": true, weshalb npm ci sie selbst
|
||||||
# resolvt Optional-Deps frisch fuer die aktuelle Plattform (= linux-arm64-musl
|
# mit --include=optional nicht installiert. --> npm install statt ci.
|
||||||
# im Docker-Build) und findet die Prebuilts korrekt. Die package.json-semver-
|
# (b) Parallel-Install laesst sharp's postinstall laufen, bevor das
|
||||||
# Ranges sorgen fuer hinreichende Reproduzierbarkeit.
|
# @img/sharp-linuxmusl-arm64-Paket entpackt ist. --> --ignore-scripts
|
||||||
RUN npm install --include=optional --no-audit --no-fund
|
# hier, dann npm rebuild mit allen Deps auf Disk. node-addon-api ist
|
||||||
|
# als devDep da, damit der from-source Fallback ebenfalls funktioniert
|
||||||
|
# (python3 + make + g++ + vips-dev sind oben installiert).
|
||||||
|
RUN npm install --ignore-scripts --include=optional --no-audit --no-fund
|
||||||
|
RUN npm rebuild
|
||||||
|
|
||||||
COPY . .
|
COPY . .
|
||||||
RUN npm run build
|
RUN npm run build
|
||||||
|
|
||||||
# Fresh-Install fuer den Runtime-Stage: nur Produktions-Deps, wieder mit
|
# Fresh-Install fuer den Runtime-Stage: nur Produktions-Deps, gleicher Ansatz.
|
||||||
# npm install statt ci aus demselben Grund wie oben.
|
|
||||||
RUN rm -rf node_modules \
|
RUN rm -rf node_modules \
|
||||||
&& npm install --omit=dev --include=optional --no-audit --no-fund
|
&& npm install --ignore-scripts --omit=dev --include=optional --no-audit --no-fund \
|
||||||
|
&& npm rebuild
|
||||||
|
|
||||||
FROM node:22-alpine AS runner
|
FROM node:22-alpine AS runner
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|||||||
10
package-lock.json
generated
10
package-lock.json
generated
@@ -15,6 +15,7 @@
|
|||||||
"better-sqlite3": "^11.5.0",
|
"better-sqlite3": "^11.5.0",
|
||||||
"linkedom": "^0.18.5",
|
"linkedom": "^0.18.5",
|
||||||
"lucide-svelte": "^1.0.1",
|
"lucide-svelte": "^1.0.1",
|
||||||
|
"node-addon-api": "^8.7.0",
|
||||||
"yauzl": "^3.3.0",
|
"yauzl": "^3.3.0",
|
||||||
"zod": "^3.23.8"
|
"zod": "^3.23.8"
|
||||||
},
|
},
|
||||||
@@ -3494,6 +3495,15 @@
|
|||||||
"node": ">=10"
|
"node": ">=10"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/node-addon-api": {
|
||||||
|
"version": "8.7.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/node-addon-api/-/node-addon-api-8.7.0.tgz",
|
||||||
|
"integrity": "sha512-9MdFxmkKaOYVTV+XVRG8ArDwwQ77XIgIPyKASB1k3JPq3M8fGQQQE3YpMOrKm6g//Ktx8ivZr8xo1Qmtqub+GA==",
|
||||||
|
"license": "MIT",
|
||||||
|
"engines": {
|
||||||
|
"node": "^18 || ^20 || >= 21"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/normalize-path": {
|
"node_modules/normalize-path": {
|
||||||
"version": "3.0.0",
|
"version": "3.0.0",
|
||||||
"resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-3.0.0.tgz",
|
"resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-3.0.0.tgz",
|
||||||
|
|||||||
@@ -42,6 +42,7 @@
|
|||||||
"better-sqlite3": "^11.5.0",
|
"better-sqlite3": "^11.5.0",
|
||||||
"linkedom": "^0.18.5",
|
"linkedom": "^0.18.5",
|
||||||
"lucide-svelte": "^1.0.1",
|
"lucide-svelte": "^1.0.1",
|
||||||
|
"node-addon-api": "^8.7.0",
|
||||||
"yauzl": "^3.3.0",
|
"yauzl": "^3.3.0",
|
||||||
"zod": "^3.23.8"
|
"zod": "^3.23.8"
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user