45 lines
831 B
Docker
45 lines
831 B
Docker
|
|
FROM node:18-alpine as builder
|
|
|
|
WORKDIR /app
|
|
|
|
# Install build dependencies
|
|
RUN apk add --no-cache python3 make g++
|
|
|
|
# Copy package files
|
|
COPY frontend/package*.json ./
|
|
|
|
# Install dependencies
|
|
RUN npm ci
|
|
|
|
# Copy source code
|
|
COPY frontend/ .
|
|
|
|
# Build the application
|
|
RUN npm run build
|
|
|
|
# Production stage
|
|
FROM nginx:alpine
|
|
|
|
# Copy nginx configuration
|
|
COPY docker/nginx.conf /etc/nginx/conf.d/default.conf
|
|
|
|
# Copy built files
|
|
COPY --from=builder /app/dist /usr/share/nginx/html
|
|
|
|
# Create non-root user
|
|
RUN addgroup -g 1001 -S nginx && \
|
|
adduser -S nginx -u 1001 -G nginx
|
|
|
|
# Set ownership
|
|
RUN chown -R nginx:nginx /usr/share/nginx/html
|
|
|
|
# Switch to non-root user
|
|
USER nginx
|
|
|
|
# Expose port
|
|
EXPOSE 80
|
|
|
|
# Health check
|
|
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
|
|
CMD curl -f http://localhost || exit 1 |