37 lines
1.2 KiB
Docker
37 lines
1.2 KiB
Docker
# ========================================
|
|
# Frontend Angular Dockerfile (multi-stage)
|
|
# ========================================
|
|
|
|
FROM node:20-alpine AS base
|
|
WORKDIR /app
|
|
COPY package*.json ./
|
|
|
|
# ========================================
|
|
# Development: ng serve con hot reload
|
|
# ========================================
|
|
FROM base AS development
|
|
RUN npm install
|
|
COPY . .
|
|
EXPOSE 4200
|
|
CMD ["npm", "run", "dev", "--", "--host", "0.0.0.0"]
|
|
|
|
# ========================================
|
|
# Build: bundle statico di produzione
|
|
# ========================================
|
|
FROM base AS build
|
|
RUN npm install
|
|
COPY . .
|
|
RUN npm run build
|
|
# Nota: la build SSR (server.ts/main.server.ts) non è al momento agganciata
|
|
# ad angular.json ("server" builder option assente), quindi ng build produce
|
|
# solo il bundle browser in dist/app/browser/. Se in futuro si abilita la SSR,
|
|
# questo stage andrà aggiornato per servire dist/app/server con Node invece di nginx.
|
|
|
|
# ========================================
|
|
# Production: bundle statico servito da nginx
|
|
# ========================================
|
|
FROM nginx:1.27-alpine AS production
|
|
COPY --from=build /app/dist/app/browser /usr/share/nginx/html
|
|
COPY nginx.conf /etc/nginx/conf.d/default.conf
|
|
EXPOSE 80
|