Skip to content
Snippets Groups Projects

Fix : Mise-à-jour du Dockerfile avec un vrai serveur de PROD. Ajout élément...

Compare and
2 files
+ 21
4
Preferences
Compare changes
Files
2
+ 18
4
FROM node:18-alpine AS builder
# Use Node.js as the base image
FROM node:20 AS builder
WORKDIR /app
COPY . .
# Set the ARG to accept during build time
ARG VITE_API_URL
# Set the environment variable for both build and runtime
ENV VITE_API_URL=${VITE_API_URL}
# Copy the package.json and install dependencies
COPY package*.json ./
RUN npm install
# Copy all the files
COPY . .
# Build the Vite project
RUN npm run build
# Nginx to serve the production build
FROM nginx:alpine
# Copy the built files from the builder image to Nginx
COPY --from=builder /app/dist /usr/share/nginx/html
# Expose port 80 for Nginx
EXPOSE 80
# Start Nginx server
CMD ["nginx", "-g", "daemon off;"]