fix: docker build - use root context for monorepo workspaces
- Change build context from ./frontend|backend to root (.) - Update Dockerfiles to copy from correct paths - Use npm install instead of npm ci (workspaces share root lockfile) - Remove obsolete version attribute from docker-compose.yml Fixes npm ci errors when package-lock.json is at workspace root.
This commit is contained in:
+15
-10
@@ -3,16 +3,18 @@ FROM node:20-alpine AS builder
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
# Copy package files
|
||||
# Copy root package files for workspace install
|
||||
COPY package*.json ./
|
||||
COPY frontend/package*.json ./frontend/
|
||||
|
||||
# Install dependencies
|
||||
RUN npm ci
|
||||
# Install dependencies using npm install (no individual lockfile in workspace)
|
||||
RUN npm install --legacy-peer-deps
|
||||
|
||||
# Copy source code
|
||||
COPY . .
|
||||
# Copy frontend source
|
||||
COPY frontend/ ./frontend/
|
||||
|
||||
# Build Next.js app
|
||||
WORKDIR /app/frontend
|
||||
RUN npm run build
|
||||
|
||||
# Production stage
|
||||
@@ -22,14 +24,17 @@ WORKDIR /app
|
||||
|
||||
# Copy package files
|
||||
COPY package*.json ./
|
||||
COPY frontend/package*.json ./frontend/
|
||||
|
||||
# Install production dependencies only
|
||||
RUN npm ci --only=production
|
||||
# Install production dependencies
|
||||
RUN npm install --legacy-peer-deps --omit=dev
|
||||
|
||||
# Copy built files from builder
|
||||
COPY --from=builder /app/.next ./.next
|
||||
COPY --from=builder /app/public ./public
|
||||
COPY --from=builder /app/next.config.js ./
|
||||
COPY --from=builder /app/frontend/.next ./frontend/.next
|
||||
COPY --from=builder /app/frontend/public ./frontend/public
|
||||
COPY --from=builder /app/frontend/next.config.js ./frontend/
|
||||
|
||||
WORKDIR /app/frontend
|
||||
|
||||
# Expose port
|
||||
EXPOSE 3000
|
||||
|
||||
Reference in New Issue
Block a user