From 9c5468fe7efa2d2868227c2dbd19968bd661ca45 Mon Sep 17 00:00:00 2001 From: nmemmert <67961292+nmemmert@users.noreply.github.com> Date: Wed, 26 Aug 2026 15:06:32 -0400 Subject: [PATCH] Switch final stage to node:20-slim for better-sqlite3 compatibility Alpine's musl libc causes repeated npm ci failures for better-sqlite3's native module compilation. node:20-slim (Debian) uses glibc and compiles reliably. Client builder stage stays Alpine since it has no native deps. Co-Authored-By: Claude Sonnet 4.6 --- Dockerfile | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/Dockerfile b/Dockerfile index 66f6836..f6628ff 100644 --- a/Dockerfile +++ b/Dockerfile @@ -16,21 +16,21 @@ COPY client/public ./public # Build React app RUN npm run build -# Final stage - Node.js server -FROM node:20-alpine +# Final stage - Node.js server (slim Debian for glibc native module compatibility) +FROM node:20-slim WORKDIR /app -# Install dumb-init for proper signal handling -RUN apk add --no-cache dumb-init +# Install dumb-init and build tools needed by better-sqlite3 +RUN apt-get update && apt-get install -y --no-install-recommends \ + dumb-init python3 make g++ \ + && rm -rf /var/lib/apt/lists/* # Copy server package files COPY package*.json ./ -# Install build tools for native modules (better-sqlite3), then install deps -RUN apk add --no-cache python3 build-base linux-headers && \ - npm ci --omit=dev && \ - apk del python3 build-base linux-headers +# Install production dependencies only +RUN npm ci --omit=dev # Copy server code COPY server ./server @@ -38,12 +38,11 @@ COPY server ./server # Copy built React client from builder stage COPY --from=client-builder /app/client/build ./client/build -# Create data directory and set permissions -RUN mkdir -p /app/data && chown -R 1001:1001 /app - -# Create non-root user -RUN addgroup -g 1001 -S nodejs && \ - adduser -S nodejs -u 1001 +# Create non-root user and data directory +RUN groupadd -g 1001 nodejs && \ + useradd -u 1001 -g nodejs nodejs && \ + mkdir -p /app/data && \ + chown -R nodejs:nodejs /app USER nodejs