-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocker-compose.yml
More file actions
127 lines (113 loc) · 3.48 KB
/
docker-compose.yml
File metadata and controls
127 lines (113 loc) · 3.48 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
# ========================================
# DOCKER COMPOSE - DEV ENVIRONMENT
# ========================================
# Questo file supporta il FACTOR X: Dev/Prod Parity
# - Stessa immagine Docker usata in produzione
# - Ambiente di sviluppo locale consistente
# - Backing services locali (esempio: PostgreSQL, Redis)
version: '3.8'
services:
# ========================================
# Application Service
# ========================================
app:
build:
context: .
dockerfile: Dockerfile # ✅ Stesso Dockerfile di produzione
image: twelve-factor-demo:1.0.0
container_name: twelve-factor-app
# FACTOR VII: Port Binding
ports:
- "8080:8080"
# FACTOR III: Config - Environment variables per dev
environment:
- SERVER_PORT=8080
- GREETING_PREFIX=Hello from Docker Compose
- APP_VERSION=1.0.0-dev
- SPRING_PROFILES_ACTIVE=dev
# FACTOR IV: Backing Services (se configurati)
# - DATABASE_URL=jdbc:postgresql://postgres:5432/devdb
# - DB_USERNAME=postgres
# - DB_PASSWORD=devpassword
# - REDIS_HOST=redis
# - REDIS_PORT=6379
# FACTOR IX: Disposability
restart: unless-stopped
# FACTOR VI: Processes - Health check
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:8080/actuator/health"]
interval: 30s
timeout: 3s
retries: 3
start_period: 40s
# Dipendenze da backing services (quando configurati)
# depends_on:
# - postgres
# - redis
# FACTOR XI: Logs - Output su stdout, Docker li raccoglie
logging:
driver: "json-file"
options:
max-size: "10m"
max-file: "3"
networks:
- twelve-factor-network
# ========================================
# FACTOR IV: Backing Services - PostgreSQL (esempio)
# ========================================
# Decommentare per aggiungere database locale
# postgres:
# image: postgres:15-alpine
# container_name: twelve-factor-postgres
# environment:
# - POSTGRES_DB=devdb
# - POSTGRES_USER=postgres
# - POSTGRES_PASSWORD=devpassword
# ports:
# - "5432:5432"
# volumes:
# - postgres_data:/var/lib/postgresql/data
# networks:
# - twelve-factor-network
# healthcheck:
# test: ["CMD-SHELL", "pg_isready -U postgres"]
# interval: 10s
# timeout: 5s
# retries: 5
# ========================================
# FACTOR IV: Backing Services - Redis (esempio)
# ========================================
# Decommentare per aggiungere cache locale
# redis:
# image: redis:7-alpine
# container_name: twelve-factor-redis
# ports:
# - "6379:6379"
# networks:
# - twelve-factor-network
# healthcheck:
# test: ["CMD", "redis-cli", "ping"]
# interval: 10s
# timeout: 3s
# retries: 5
# ========================================
# FACTOR XII: Admin - Prometheus (monitoring - opzionale)
# ========================================
# Decommentare per monitoring locale
# prometheus:
# image: prom/prometheus:latest
# container_name: twelve-factor-prometheus
# ports:
# - "9090:9090"
# volumes:
# - ./monitoring/prometheus.yml:/etc/prometheus/prometheus.yml
# networks:
# - twelve-factor-network
# command:
# - '--config.file=/etc/prometheus/prometheus.yml'
networks:
twelve-factor-network:
driver: bridge
# volumes:
# postgres_data:
# redis_data: