diff --git a/Dockerfile b/Dockerfile index ab66df9..7fc2f6a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -3,9 +3,15 @@ FROM node:20-alpine AS frontend-builder WORKDIR /app/frontend -# Copy frontend package files and install ALL dependencies (including devDependencies for build) +# Copy frontend package files COPY frontend/package*.json ./ -RUN npm ci + +# Generate lockfile if it doesn't exist, then install dependencies +RUN if [ ! -f package-lock.json ]; then \ + echo "Generating package-lock.json..."; \ + npm install --package-lock-only; \ + fi && \ + npm ci # Copy frontend source and build COPY frontend/ ./ @@ -16,9 +22,15 @@ FROM node:20-alpine AS backend-builder WORKDIR /app/backend -# Copy backend package files and install ALL dependencies (including TypeScript) +# Copy backend package files COPY backend/package*.json ./ -RUN npm ci + +# Generate lockfile if it doesn't exist, then install dependencies +RUN if [ ! -f package-lock.json ]; then \ + echo "Generating package-lock.json..."; \ + npm install --package-lock-only; \ + fi && \ + npm ci # Copy backend source and compile TypeScript COPY backend/ ./ @@ -29,9 +41,15 @@ FROM node:20-alpine WORKDIR /app -# Install production dependencies only +# Copy backend package files COPY backend/package*.json ./ -RUN npm ci --only=production && \ + +# Generate lockfile if it doesn't exist, then install production dependencies only +RUN if [ ! -f package-lock.json ]; then \ + echo "Generating package-lock.json..."; \ + npm install --package-lock-only; \ + fi && \ + npm ci --omit=dev && \ npm cache clean --force # Copy compiled backend from builder