# Stage 1: Build FROM node:20-alpine AS builder # Métadonnées LABEL maintainer="Yt2Jellyfin" LABEL description="Frontend React pour Yt2Jellyfin" # Définir le répertoire de travail WORKDIR /app # Copier les fichiers de dépendances COPY package*.json ./ # Installer les dépendances (avec cache npm) RUN npm ci --only=production # Copier le code source COPY . . # Build de l'application RUN npm run build # Stage 2: Production avec Nginx FROM nginx:1.25-alpine AS production # Installer des outils de sécurité et nettoyer RUN apk add --no-cache \ ca-certificates \ tzdata \ && rm -rf /var/cache/apk/* # Créer un utilisateur non-root RUN addgroup -g 1001 -S nginx-app && \ adduser -S -D -H -u 1001 -h /var/cache/nginx -s /sbin/nologin -G nginx-app -g nginx-app nginx-app # Copier les fichiers buildés depuis le stage builder COPY --from=builder --chown=nginx-app:nginx-app /app/dist /usr/share/nginx/html # Configuration Nginx sécurisée COPY --chown=nginx-app:nginx-app <