npm ci can also OOM during dependency installation. Move the heap limit before npm ci so it applies to all Node processes. Bump Drone pod limits to 4Gi (requests 2Gi) to cover Docker-in-Docker overhead.
32 lines
748 B
Docker
32 lines
748 B
Docker
# Stage 1: Build the React app
|
|
FROM node:24-alpine AS builder
|
|
|
|
WORKDIR /app
|
|
|
|
# Limit Node.js heap to avoid OOM in constrained CI environments
|
|
ENV NODE_OPTIONS="--max-old-space-size=1024"
|
|
|
|
# Copy package files first for better caching
|
|
COPY package.json package-lock.json* ./
|
|
|
|
RUN npm ci
|
|
|
|
# Copy all files and build
|
|
COPY . .
|
|
|
|
# Skip tsc type-checking (already done in test step); Vite transpiles via SWC
|
|
RUN npx vite build
|
|
|
|
FROM nginx:alpine
|
|
|
|
# Remove default nginx static files
|
|
RUN rm -rf /usr/share/nginx/html/*
|
|
|
|
WORKDIR /app
|
|
|
|
# Copy only necessary files from the builder stage
|
|
COPY --from=builder /app/dist /usr/share/nginx/html
|
|
COPY --from=builder /app/nginx.conf /etc/nginx/conf.d/default.conf
|
|
|
|
EXPOSE 80
|
|
CMD ["nginx", "-g", "daemon off;"]
|