-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocker-compose.yml
More file actions
58 lines (53 loc) · 1.57 KB
/
Copy pathdocker-compose.yml
File metadata and controls
58 lines (53 loc) · 1.57 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
version: '3.9'
services:
web:
image: nginx:latest # Specifies the image to use
container_name: my_nginx_container # Name for the container
restart: always # Restart policy: no, always, on-failure, unless-stopped
ports:
- "80:80" # Maps port 80 on host to 80 in container
environment:
- NGINX_HOST=${NGINX_HOST} # Environment variables from .env file
- NGINX_PORT=${NGINX_PORT}
env_file:
- .env # Load environment variables from .env file
volumes:
- ./nginx.conf:/etc/nginx/nginx.conf # Mount a volume
networks:
- my_network
depends_on:
- db # Ensures web starts after db
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost"] # Check service health
interval: 30s # Run health check every 30s
retries: 3 # Number of retries before marking unhealthy
timeout: 10s
db:
image: postgres:latest
container_name: my_postgres_container
restart: unless-stopped
ports:
- "5432:5432"
environment:
POSTGRES_USER: ${POSTGRES_USER}
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
POSTGRES_DB: ${POSTGRES_DB}
env_file:
- .env # Load environment variables from .env file
volumes:
- pg_data:/var/lib/postgresql/data
networks:
- my_network
redis:
image: redis:latest
container_name: my_redis_container
restart: on-failure
ports:
- "6379:6379"
networks:
- my_network
volumes:
pg_data: # Named volume to persist PostgreSQL data
networks:
my_network:
driver: bridge # Network driver type