37 lines
697 B
Docker
37 lines
697 B
Docker
|
|
# Build stage
|
||
|
|
FROM node:20-alpine AS builder
|
||
|
|
|
||
|
|
# Install pnpm
|
||
|
|
RUN npm install -g pnpm@9.0.0
|
||
|
|
|
||
|
|
WORKDIR /app
|
||
|
|
|
||
|
|
# Copy package files
|
||
|
|
COPY package.json pnpm-lock.yaml* ./
|
||
|
|
|
||
|
|
# Install dependencies
|
||
|
|
RUN pnpm install --frozen-lockfile
|
||
|
|
|
||
|
|
# Copy source code
|
||
|
|
COPY . .
|
||
|
|
|
||
|
|
# Generate static site
|
||
|
|
RUN pnpm run generate
|
||
|
|
|
||
|
|
# Production stage
|
||
|
|
FROM nginx:alpine
|
||
|
|
|
||
|
|
# Copy custom nginx config
|
||
|
|
COPY nginx.conf /etc/nginx/nginx.conf
|
||
|
|
|
||
|
|
# Copy built static site
|
||
|
|
COPY --from=builder /app/.output/public /usr/share/nginx/html
|
||
|
|
|
||
|
|
# Add healthcheck
|
||
|
|
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
|
||
|
|
CMD wget --quiet --tries=1 --spider http://localhost:80/ || exit 1
|
||
|
|
|
||
|
|
EXPOSE 80
|
||
|
|
|
||
|
|
CMD ["nginx", "-g", "daemon off;"]
|