Update Dockerfile to auto-generate lockfiles during build
This commit is contained in:
30
Dockerfile
30
Dockerfile
@@ -3,9 +3,15 @@ FROM node:20-alpine AS frontend-builder
|
|||||||
|
|
||||||
WORKDIR /app/frontend
|
WORKDIR /app/frontend
|
||||||
|
|
||||||
# Copy frontend package files and install ALL dependencies (including devDependencies for build)
|
# Copy frontend package files
|
||||||
COPY frontend/package*.json ./
|
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 source and build
|
||||||
COPY frontend/ ./
|
COPY frontend/ ./
|
||||||
@@ -16,9 +22,15 @@ FROM node:20-alpine AS backend-builder
|
|||||||
|
|
||||||
WORKDIR /app/backend
|
WORKDIR /app/backend
|
||||||
|
|
||||||
# Copy backend package files and install ALL dependencies (including TypeScript)
|
# Copy backend package files
|
||||||
COPY backend/package*.json ./
|
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 source and compile TypeScript
|
||||||
COPY backend/ ./
|
COPY backend/ ./
|
||||||
@@ -29,9 +41,15 @@ FROM node:20-alpine
|
|||||||
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
# Install production dependencies only
|
# Copy backend package files
|
||||||
COPY backend/package*.json ./
|
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
|
npm cache clean --force
|
||||||
|
|
||||||
# Copy compiled backend from builder
|
# Copy compiled backend from builder
|
||||||
|
|||||||
Reference in New Issue
Block a user