28 lines
665 B
Docker
28 lines
665 B
Docker
# Build stage
|
|
FROM node:20-alpine AS builder
|
|
WORKDIR /app
|
|
|
|
# Install build dependencies and pnpm (via corepack)
|
|
RUN apk add --no-cache python3 make g++ && \
|
|
corepack enable && corepack prepare pnpm@latest --activate
|
|
|
|
# Copy package manifests first for better caching
|
|
COPY package.json pnpm-lock.yaml ./
|
|
|
|
# Copy the rest of the project
|
|
COPY . .
|
|
|
|
# Install deps and build
|
|
RUN pnpm install --frozen-lockfile
|
|
RUN pnpm build
|
|
|
|
# Production image
|
|
FROM nginx:stable-alpine
|
|
COPY --from=builder /app/dist /usr/share/nginx/html
|
|
|
|
# Add custom nginx config for SPA routing
|
|
COPY docker/nginx.conf /etc/nginx/conf.d/default.conf
|
|
|
|
EXPOSE 80
|
|
|
|
CMD ["nginx", "-g", "daemon off;"]
|