chore(docker): ristruttura Dockerfile e docker-compose per produzione

- Multi-stage build: builder (npm ci + vite build) + runtime minimale
- Immagine runtime senza devDependencies e senza sorgenti frontend
- docker-compose: porta singola 3000, volume .segnapunti per persistenza stato
- Aggiunge .dockerignore per escludere node_modules, test, dist dal contesto
This commit is contained in:
2026-05-12 14:21:32 +02:00
parent 1a43864919
commit f38c0eaf72
3 changed files with 34 additions and 15 deletions
+11
View File
@@ -0,0 +1,11 @@
node_modules
dist
dev-dist
.segnapunti
tests
playwright-report
test-results
*.md
.git
.gitignore
.vscode
+16 -12
View File
@@ -1,18 +1,22 @@
# Stage 1: build frontend
FROM node:20-alpine AS builder
WORKDIR /usr/src/app
# Copia tutto
WORKDIR /app
COPY package*.json ./
RUN npm ci
COPY . .
RUN npm run build
# Aggiunge GIT ma serve solo se si vuole evidenziare un hash del commit
RUN apk add git
# Stage 2: runtime
FROM node:20-alpine
WORKDIR /app
ENV NODE_ENV=production PORT=3000
# aggiunge l'ultima versione di node
RUN npm install -g npm@latest
# Installa tutte le dipendenze del progetto
RUN npm install
COPY package*.json ./
RUN npm ci --omit=dev
# Qui fa partire il comando...
# Per adesso è dev perchè non ho capito bene il tutto... (Attilio)
CMD ["npm", "run", "serve"]
COPY server.js ./
COPY src/gameState.js src/websocket-handler.js src/server-utils.js src/persist.js ./src/
COPY --from=builder /app/dist ./dist
EXPOSE 3000
CMD ["node", "server.js"]
+7 -3
View File
@@ -1,8 +1,12 @@
services:
segnapunti:
build: .
container_name: segnapunti
ports:
- 3000:3000
- 3001:3001
container_name: segnapunti-container
- "3000:3000"
volumes:
- segnapunti-state:/app/.segnapunti
restart: unless-stopped
volumes:
segnapunti-state: