Docker Build and Push / build (push) Failing after 3m3s
react-scripts@5.0.1 declares peer deps against React 17/18; adding --legacy-peer-deps lets npm ci succeed without changing the lockfile. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
56 lines
1.1 KiB
Docker
56 lines
1.1 KiB
Docker
# Build stage for React client
|
|
FROM node:20-alpine AS client-builder
|
|
|
|
WORKDIR /app/client
|
|
|
|
# Copy client package files
|
|
COPY client/package*.json ./
|
|
|
|
# Install dependencies (--legacy-peer-deps needed for react-scripts 5 + React 19)
|
|
RUN npm ci --legacy-peer-deps
|
|
|
|
# Copy client source
|
|
COPY client/src ./src
|
|
COPY client/public ./public
|
|
|
|
# Build React app
|
|
RUN npm run build
|
|
|
|
# Final stage - Node.js server
|
|
FROM node:20-alpine
|
|
|
|
WORKDIR /app
|
|
|
|
# Install dumb-init for proper signal handling
|
|
RUN apk add --no-cache dumb-init
|
|
|
|
# Copy server package files
|
|
COPY package*.json ./
|
|
|
|
# Install production dependencies only
|
|
RUN npm ci --only=production
|
|
|
|
# Copy server code
|
|
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
|
|
|
|
USER nodejs
|
|
|
|
# Expose port
|
|
EXPOSE 3001
|
|
|
|
# Use dumb-init to handle signals properly
|
|
ENTRYPOINT ["dumb-init", "--"]
|
|
|
|
# Start the server
|
|
CMD ["node", "server/index.js"]
|