fix: upgrade to bookworm-slim as base

This commit is contained in:
Benno Tielen 2026-02-18 07:27:29 +01:00
parent 48af8a0063
commit 90b33909f6

View file

@ -1,8 +1,6 @@
# From https://github.com/vercel/next.js/blob/canary/examples/with-docker/Dockerfile FROM node:22-bookworm-slim AS base
FROM node:22-alpine AS base
RUN corepack enable; RUN corepack enable;
RUN apk add --no-cache libc6-compat
# Install dependencies only when needed # Install dependencies only when needed
FROM base AS deps FROM base AS deps
@ -12,7 +10,7 @@ WORKDIR /app
COPY package.json yarn.lock* .yarnrc.yml package-lock.json* pnpm-lock.yaml* ./ COPY package.json yarn.lock* .yarnrc.yml package-lock.json* pnpm-lock.yaml* ./
RUN \ RUN \
if [ -f yarn.lock ]; then yarn --frozen-lockfile; \ if [ -f yarn.lock ]; then yarn --frozen-lockfile; \
elif [ -f package-lock.json ]; then npm ci && npm install --os=linux --libc=musl --cpu=x64 sharp; \ elif [ -f package-lock.json ]; then npm ci; \
elif [ -f pnpm-lock.yaml ]; then corepack enable pnpm && pnpm i --frozen-lockfile; \ elif [ -f pnpm-lock.yaml ]; then corepack enable pnpm && pnpm i --frozen-lockfile; \
else echo "Lockfile not found." && exit 1; \ else echo "Lockfile not found." && exit 1; \
fi fi
@ -42,8 +40,9 @@ WORKDIR /app
ENV NODE_ENV=production ENV NODE_ENV=production
RUN addgroup -g 1001 -S nodejs # Use groupadd and useradd (standard Linux tools) instead of Alpine's syntax
RUN adduser -S nextjs -u 1001 RUN groupadd --gid 1001 nodejs
RUN useradd --uid 1001 --gid nodejs --shell /bin/bash --create-home nextjs
# Automatically leverage output traces to reduce image size # Automatically leverage output traces to reduce image size
# https://nextjs.org/docs/advanced-features/output-file-tracing # https://nextjs.org/docs/advanced-features/output-file-tracing