# DrAgnes Dockerfile — Multi-stage build for Cloud Run # Stage 1: Build SvelteKit application # Stage 2: Production image with minimal footprint # ---- Build stage ------------------------------------------------------------- FROM node:20-alpine AS build WORKDIR /app # Copy package files first for layer caching COPY package.json package-lock.json ./ RUN npm ci --ignore-scripts # Copy source and build COPY . . RUN npm run build # ---- Production stage -------------------------------------------------------- FROM node:20-alpine AS production RUN addgroup -g 1001 -S dragnes && \ adduser -S dragnes -u 1001 -G dragnes WORKDIR /app # Copy built output and production dependencies COPY --from=build /app/build ./build COPY --from=build /app/node_modules ./node_modules COPY --from=build /app/package.json ./package.json # Copy WASM assets COPY --from=build /app/static/wasm ./build/client/wasm COPY --from=build /app/static/manifest.json ./build/client/manifest.json COPY --from=build /app/static/dragnes-icon-192.svg ./build/client/dragnes-icon-192.svg COPY --from=build /app/static/dragnes-icon-512.svg ./build/client/dragnes-icon-512.svg COPY --from=build /app/static/sw.js ./build/client/sw.js # Set environment ENV NODE_ENV=production ENV PORT=3000 ENV HOST=0.0.0.0 EXPOSE 3000 # Health check HEALTHCHECK --interval=30s --timeout=5s --start-period=10s --retries=3 \ CMD wget -qO- http://localhost:3000/api/health || exit 1 # Run as non-root USER dragnes CMD ["node", "build/index.js"]