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 FROM node:20-alpine AS builder
WORKDIR /app
WORKDIR /usr/src/app COPY package*.json ./
# Copia tutto RUN npm ci
COPY . . COPY . .
RUN npm run build
# Aggiunge GIT ma serve solo se si vuole evidenziare un hash del commit # Stage 2: runtime
RUN apk add git FROM node:20-alpine
WORKDIR /app
ENV NODE_ENV=production PORT=3000
# aggiunge l'ultima versione di node COPY package*.json ./
RUN npm install -g npm@latest RUN npm ci --omit=dev
# Installa tutte le dipendenze del progetto
RUN npm install
# Qui fa partire il comando... COPY server.js ./
# Per adesso è dev perchè non ho capito bene il tutto... (Attilio) COPY src/gameState.js src/websocket-handler.js src/server-utils.js src/persist.js ./src/
CMD ["npm", "run", "serve"] COPY --from=builder /app/dist ./dist
EXPOSE 3000
CMD ["node", "server.js"]
+7 -3
View File
@@ -1,8 +1,12 @@
services: services:
segnapunti: segnapunti:
build: . build: .
container_name: segnapunti
ports: ports:
- 3000:3000 - "3000:3000"
- 3001:3001 volumes:
container_name: segnapunti-container - segnapunti-state:/app/.segnapunti
restart: unless-stopped
volumes:
segnapunti-state: