Files
drone-detector/client/Dockerfile
2025-09-06 16:15:59 +02:00

57 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 install --production=false
# Copy source code
COPY . .
# Build arguments for environment variables
ARG VITE_BASE_PATH=/uggla/
ARG VITE_API_URL
ARG NODE_ENV=production
# Set environment variables for build
ENV VITE_BASE_PATH=$VITE_BASE_PATH
ENV VITE_API_URL=$VITE_API_URL
ENV NODE_ENV=$NODE_ENV
# 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 nginx configuration
COPY nginx.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;"]