All checks were successful
Build & Publish Docker Image / build-and-push (push) Successful in 3m5s
Finaler Anlauf gegen den arm64-Build-Fehler. Bisher scheiterte npm daran, @img/sharp-linuxmusl-arm64 unter Docker-Buildx-QEMU zu installieren, trotz --include=optional. Mehrschichtiger Fix: 1. --cpu=arm64 --os=linux --libc=musl auf npm install: umgeht QEMU- bezogene Detection-Bugs (sharp's offiziell empfohlener Fix). 2. Expliziter Zusatz-Install von @img/sharp-linuxmusl-arm64 und @img/sharp-libvips-linuxmusl-arm64: zwingt die Prebuilts auf Disk, unabhaengig von der Lockfile-Resolution. 3. --ignore-scripts beim Install + npm rebuild danach: loest den Race, wo sharp's postinstall laeuft bevor der Prebuilt-Tarball fertig ist. 4. node-addon-api + node-gyp als Runtime-Deps: from-source-Build- Fallback falls alle Prebuilt-Pfade scheitern. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
67 lines
2.4 KiB
Docker
67 lines
2.4 KiB
Docker
# syntax=docker/dockerfile:1.7
|
|
|
|
FROM node:22-alpine AS builder
|
|
WORKDIR /app
|
|
|
|
# Alpine needs build tools for better-sqlite3 native module.
|
|
# vips-dev provides libvips + libheif for sharp (incl. HEIC input from iOS).
|
|
RUN apk add --no-cache python3 make g++ libc6-compat vips-dev
|
|
|
|
COPY package*.json ./
|
|
# Sharp-Prebuilt-Install unter Docker-Buildx-QEMU war trotz aller Flag-
|
|
# Varianten unzuverlaessig. Finale Strategie:
|
|
# - --cpu/--os/--libc explizit setzen: sharp's offizielle Doc-Empfehlung
|
|
# fuer Cross-Platform-Docker-Builds (siehe sharp-Install-Doku),
|
|
# umgeht QEMU-Detection-Bugs.
|
|
# - --ignore-scripts + npm rebuild: loest das Parallel-Install-Race,
|
|
# bei dem sharp's install-Skript vor dem Entpacken der Prebuilt-Binary
|
|
# laeuft.
|
|
# - Explizites Nachinstallieren der Prebuilts als Sicherheit: falls (A)
|
|
# noch nicht reicht, zwingt (B) die Plattform-Pakete auf Disk.
|
|
# - node-addon-api + node-gyp als Runtime-Deps: falls am Ende doch alles
|
|
# nicht klappt und sharp from-source baut (mit dem oben installierten
|
|
# python3 + make + g++ + vips-dev).
|
|
RUN npm install --cpu=arm64 --os=linux --libc=musl \
|
|
--ignore-scripts --include=optional --no-audit --no-fund
|
|
RUN npm install --cpu=arm64 --os=linux --libc=musl \
|
|
--ignore-scripts --no-save --no-audit --no-fund \
|
|
@img/sharp-linuxmusl-arm64@0.34.5 \
|
|
@img/sharp-libvips-linuxmusl-arm64@1.2.4
|
|
RUN npm rebuild
|
|
|
|
COPY . .
|
|
RUN npm run build
|
|
|
|
# Fresh-Install fuer den Runtime-Stage: nur Produktions-Deps, gleiche Strategie.
|
|
RUN rm -rf node_modules \
|
|
&& npm install --cpu=arm64 --os=linux --libc=musl \
|
|
--ignore-scripts --omit=dev --include=optional --no-audit --no-fund \
|
|
&& npm install --cpu=arm64 --os=linux --libc=musl \
|
|
--ignore-scripts --no-save --no-audit --no-fund \
|
|
@img/sharp-linuxmusl-arm64@0.34.5 \
|
|
@img/sharp-libvips-linuxmusl-arm64@1.2.4 \
|
|
&& npm rebuild
|
|
|
|
FROM node:22-alpine AS runner
|
|
WORKDIR /app
|
|
|
|
RUN apk add --no-cache libc6-compat
|
|
|
|
COPY --from=builder /app/build ./build
|
|
COPY --from=builder /app/node_modules ./node_modules
|
|
COPY --from=builder /app/package.json ./package.json
|
|
|
|
ENV NODE_ENV=production
|
|
ENV HOST=0.0.0.0
|
|
ENV PORT=3000
|
|
ENV DATABASE_PATH=/data/kochwas.db
|
|
ENV IMAGE_DIR=/data/images
|
|
|
|
VOLUME ["/data"]
|
|
EXPOSE 3000
|
|
|
|
HEALTHCHECK --interval=15s --timeout=5s --retries=3 --start-period=20s --start-interval=2s \
|
|
CMD wget -qO- http://127.0.0.1:3000/api/health > /dev/null || exit 1
|
|
|
|
CMD ["node", "build/index.js"]
|