first commit
This commit is contained in:
45
frontend/frontend.Dockerfile
Normal file
45
frontend/frontend.Dockerfile
Normal file
@@ -0,0 +1,45 @@
|
||||
# --- STAGE 1: Sviluppo (Node LTS) ---
|
||||
FROM node:lts-alpine3.24 AS development
|
||||
ENV NODE_OPTIONS="--max-old-space-size=4096"
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
# In sviluppo il sorgente arriva dal bind-mount (./frontend:/app) e i node_modules
|
||||
# dall'immagine via volume anonimo (/app/node_modules): NON si copia il sorgente qui.
|
||||
# Vantaggi: niente build fragile su index.html/src mancanti, nessun COPY ricorsivo
|
||||
# (docker:S6470) e i node_modules musl dell'immagine schermano quelli glibc dell'host.
|
||||
COPY package*.json ./
|
||||
RUN npm install
|
||||
|
||||
EXPOSE 5173
|
||||
CMD ["npm", "run", "dev", "--", "--host", "0.0.0.0"]
|
||||
|
||||
# --- STAGE 2: Build (Node LTS) ---
|
||||
FROM node:lts-alpine3.24 AS build
|
||||
|
||||
LABEL maintainer="Giuseppe Naponiello"
|
||||
LABEL version="3.0"
|
||||
LABEL description="Dynamic Collections Plus, frontend container (build stage)."
|
||||
|
||||
ENV NODE_OPTIONS="--max-old-space-size=4096"
|
||||
WORKDIR /app
|
||||
COPY package*.json ./
|
||||
|
||||
# npm ci richiede package-lock.json (deterministico). Fallback a install se assente.
|
||||
# Servono le devDependencies (Vite, TypeScript) per compilare: NON usare --omit=dev.
|
||||
RUN if [ -f package-lock.json ]; then npm ci; else npm install; fi
|
||||
|
||||
# Copie esplicite (no `COPY . .` — docker:S6470): non sovrascrivere i node_modules
|
||||
# musl appena installati con quelli glibc dell'host, né copiare segreti/file locali.
|
||||
COPY vite.config.ts tsconfig.json index.html ./
|
||||
COPY src/ ./src/
|
||||
COPY public/ ./public/
|
||||
RUN npm run build
|
||||
|
||||
# --- STAGE 3: Produzione (Nginx stable, patchato) ---
|
||||
FROM nginx:1.30-alpine AS production
|
||||
COPY nginx.conf /etc/nginx/conf.d/default.conf
|
||||
COPY --from=build /app/dist /usr/share/nginx/html
|
||||
|
||||
EXPOSE 80
|
||||
CMD ["nginx", "-g", "daemon off;"]
|
||||
Reference in New Issue
Block a user