Files
drone-detector/client/Dockerfile
2025-08-16 19:43:44 +02:00

55 lines
1.2 KiB
Docker

# Frontend Dockerfile for Drone Detection System
# Multi-stage build for optimized production image
# Build stage
FROM node:18-alpine AS builder
# Set working directory
WORKDIR /app
# Copy package files
COPY package*.json ./
# Install dependencies (including dev dependencies for build)
RUN npm ci
# Copy source code
COPY . .
# Build arguments for environment variables
ARG VITE_API_URL=http://localhost:3001/api
ARG VITE_WS_URL=ws://localhost:3001
# Set environment variables for build
ENV VITE_API_URL=$VITE_API_URL
ENV VITE_WS_URL=$VITE_WS_URL
# Build the application
RUN npm run build
# Production stage
FROM nginx:alpine AS production
# Install curl for health checks
RUN apk add --no-cache curl
# Copy built application from builder stage
COPY --from=builder /app/dist /usr/share/nginx/html
# Copy custom nginx configuration
COPY docker/nginx/default.conf /etc/nginx/conf.d/default.conf
# Create nginx user and set permissions
RUN chown -R nginx:nginx /usr/share/nginx/html && \
chmod -R 755 /usr/share/nginx/html
# Expose port 80
EXPOSE 80
# Health check
HEALTHCHECK --interval=30s --timeout=10s --start-period=30s --retries=3 \
CMD curl -f http://localhost:80 || exit 1
# Start nginx
CMD ["nginx", "-g", "daemon off;"]