51 lines
1.3 KiB
Docker
Executable File
51 lines
1.3 KiB
Docker
Executable File
# Multi-stage build pour la production
|
|
FROM node:18-alpine AS builder
|
|
|
|
# Métadonnées
|
|
LABEL maintainer="LeDiscord Team"
|
|
LABEL version="1.0"
|
|
LABEL description="LeDiscord Frontend - Build Production"
|
|
|
|
WORKDIR /app
|
|
|
|
# Variables d'environnement pour la production
|
|
ENV NODE_ENV=production
|
|
ENV VITE_ENVIRONMENT=production
|
|
|
|
# Copy package files first for better caching
|
|
COPY package*.json ./
|
|
|
|
# Install dependencies
|
|
RUN npm ci
|
|
|
|
# Copy application files
|
|
COPY . .
|
|
|
|
# Copy production environment file
|
|
COPY .env.production .env
|
|
|
|
# Debug: Vérifier le contenu du fichier .env
|
|
RUN echo "=== Contenu du fichier .env ===" && cat .env
|
|
RUN echo "=== Variables d'environnement ===" && env | grep VITE
|
|
|
|
# Charger les variables d'environnement depuis le fichier .env (en filtrant les commentaires)
|
|
RUN export $(cat .env | grep -v '^#' | grep -v '^$' | xargs) && echo "=== Variables après export ===" && env | grep VITE
|
|
|
|
# Build the application avec les variables d'environnement chargées
|
|
RUN export $(cat .env | grep -v '^#' | grep -v '^$' | xargs) && npm run build
|
|
|
|
# Production stage
|
|
FROM nginx:alpine
|
|
|
|
# Copy built application
|
|
COPY --from=builder /app/dist /usr/share/nginx/html
|
|
|
|
# Copy nginx configuration
|
|
COPY nginx-frontend.conf /etc/nginx/nginx.conf
|
|
|
|
# Expose port
|
|
EXPOSE 80
|
|
|
|
# Start nginx
|
|
CMD ["nginx", "-g", "daemon off;"]
|