84dd370673
- Install python3, make, g++ in builder for native module compilation - Copy node_modules from builder stage to avoid rebuild in production - Fixes usb package compilation error in node:20-alpine
47 lines
985 B
Docker
47 lines
985 B
Docker
# Build stage
|
|
FROM node:20-alpine AS builder
|
|
|
|
WORKDIR /app
|
|
|
|
# Install build tools for native modules
|
|
RUN apk add --no-cache python3 make g++
|
|
|
|
# Copy root package files for workspace install
|
|
COPY package*.json ./
|
|
COPY frontend/package*.json ./frontend/
|
|
|
|
# Install dependencies
|
|
RUN npm install --legacy-peer-deps
|
|
|
|
# Copy frontend source
|
|
COPY frontend/ ./frontend/
|
|
|
|
# Build Next.js app
|
|
WORKDIR /app/frontend
|
|
RUN npm run build
|
|
|
|
# Production stage
|
|
FROM node:20-alpine
|
|
|
|
WORKDIR /app
|
|
|
|
# Copy package files
|
|
COPY package*.json ./
|
|
COPY frontend/package*.json ./frontend/
|
|
|
|
# Copy node_modules from builder (includes compiled native modules)
|
|
COPY --from=builder /app/node_modules ./node_modules
|
|
|
|
# Copy built files from builder
|
|
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
|
|
|
|
# Start application
|
|
CMD ["npm", "start"]
|