29 lines
705 B
Docker
29 lines
705 B
Docker
# Build Stage
|
|
FROM node:20-alpine as build
|
|
WORKDIR /app
|
|
|
|
# Copiamo solo il package.json inizialmente
|
|
COPY package.json ./
|
|
|
|
# PASSAGGIO CRUCIALE: Rimuoviamo eventuali lock file vecchi e forziamo installazione pulita
|
|
RUN rm -rf package-lock.json node_modules
|
|
RUN npm install
|
|
|
|
# Copiamo tutto il resto del codice sorgente
|
|
COPY . .
|
|
|
|
# Eseguiamo la build di Vite
|
|
RUN npm run build
|
|
|
|
# Production Stage con Nginx
|
|
FROM nginx:alpine
|
|
|
|
# Copia la configurazione Nginx custom
|
|
COPY nginx.conf /etc/nginx/conf.d/default.conf
|
|
|
|
# Copia i file compilati dalla fase di build nella cartella di Nginx
|
|
COPY --from=build /app/dist /usr/share/nginx/html
|
|
|
|
EXPOSE 80
|
|
CMD ["nginx", "-g", "daemon off;"]
|