93 lines
3.8 KiB
YAML
93 lines
3.8 KiB
YAML
services:
|
|
|
|
# ─────────────────────────────────────────────
|
|
# PHP-FPM: esegue il codice Laravel
|
|
# ─────────────────────────────────────────────
|
|
app:
|
|
build:
|
|
context: .
|
|
dockerfile: docker/php/Dockerfile
|
|
container_name: portale_app
|
|
restart: unless-stopped
|
|
working_dir: /var/www
|
|
volumes:
|
|
- .:/var/www
|
|
- ./docker/php/php.ini:/usr/local/etc/php/conf.d/custom.ini
|
|
# env_file carica tutte le variabili da .env nel container.
|
|
# In produzione usa Docker Secrets o un vault invece del file .env.
|
|
env_file:
|
|
- .env
|
|
networks:
|
|
- portale_network
|
|
depends_on:
|
|
db:
|
|
condition: service_healthy
|
|
|
|
# ─────────────────────────────────────────────
|
|
# NGINX: web server che fa da "proxy" verso PHP
|
|
# ─────────────────────────────────────────────
|
|
webserver:
|
|
image: nginx:1.25-alpine
|
|
container_name: portale_nginx
|
|
restart: unless-stopped
|
|
ports:
|
|
- "${NGINX_PORT:-8080}:80" # Accessibile su http://localhost:8080
|
|
volumes:
|
|
- .:/var/www
|
|
- ./docker/nginx/default.conf:/etc/nginx/conf.d/default.conf
|
|
networks:
|
|
- portale_network
|
|
depends_on:
|
|
- app
|
|
|
|
# ─────────────────────────────────────────────
|
|
# MySQL: database relazionale
|
|
# ─────────────────────────────────────────────
|
|
db:
|
|
image: mysql:8.0
|
|
container_name: portale_db
|
|
restart: unless-stopped
|
|
environment:
|
|
MYSQL_ROOT_PASSWORD: ${DB_ROOT_PASSWORD}
|
|
MYSQL_DATABASE: ${DB_DATABASE}
|
|
MYSQL_USER: ${DB_USERNAME}
|
|
MYSQL_PASSWORD: ${DB_PASSWORD}
|
|
ports:
|
|
- "${DB_EXTERNAL_PORT:-3306}:3306" # Esposto per accesso con GUI (TablePlus, DBeaver…)
|
|
volumes:
|
|
- portale_db_data:/var/lib/mysql # Volume persistente: i dati non si perdono al restart
|
|
networks:
|
|
- portale_network
|
|
healthcheck:
|
|
test: ["CMD", "mysqladmin", "ping", "-h", "localhost", "-u", "root", "-p${DB_ROOT_PASSWORD}"]
|
|
interval: 10s
|
|
timeout: 5s
|
|
retries: 5
|
|
|
|
# ─────────────────────────────────────────────
|
|
# Redis: cache e sessioni veloci
|
|
# ─────────────────────────────────────────────
|
|
redis:
|
|
image: redis:7-alpine
|
|
container_name: portale_redis
|
|
restart: unless-stopped
|
|
command: redis-server --requirepass ${REDIS_PASSWORD}
|
|
ports:
|
|
- "${REDIS_EXTERNAL_PORT:-6379}:6379"
|
|
networks:
|
|
- portale_network
|
|
|
|
# ─────────────────────────────────────────────
|
|
# Volumi nominati: Docker gestisce la persistenza
|
|
# ─────────────────────────────────────────────
|
|
volumes:
|
|
portale_db_data:
|
|
|
|
# ─────────────────────────────────────────────
|
|
# Rete interna: i container si parlano per nome
|
|
# (es. il PHP si connette al DB con host "db")
|
|
# ─────────────────────────────────────────────
|
|
networks:
|
|
portale_network:
|
|
driver: bridge
|