43 lines
806 B
Docker
43 lines
806 B
Docker
# Build stage
|
|
FROM node:18-alpine AS builder
|
|
|
|
WORKDIR /app
|
|
|
|
# Copy package files
|
|
COPY package.json package-lock.json* ./
|
|
|
|
# Install dependencies
|
|
RUN npm ci
|
|
|
|
# Copy source code
|
|
COPY . .
|
|
|
|
# Build application
|
|
RUN npm run build
|
|
|
|
# Runtime stage
|
|
FROM nginx:alpine
|
|
|
|
# Remove default nginx config
|
|
RUN rm /etc/nginx/conf.d/default.conf
|
|
|
|
# Copy custom nginx config
|
|
COPY nginx.conf /etc/nginx/conf.d/
|
|
|
|
# Copy built application from builder
|
|
COPY --from=builder /app/dist /usr/share/nginx/html
|
|
|
|
# Create directory for environment script
|
|
RUN mkdir -p /usr/share/nginx/html/config
|
|
|
|
# Expose port
|
|
EXPOSE 80
|
|
|
|
# Health check
|
|
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
|
|
CMD wget --quiet --tries=1 --spider http://localhost/health || exit 1
|
|
|
|
# Start nginx
|
|
CMD ["nginx", "-g", "daemon off;"]
|
|
|