-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocker-compose.yml
More file actions
111 lines (106 loc) · 2.54 KB
/
Copy pathdocker-compose.yml
File metadata and controls
111 lines (106 loc) · 2.54 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
services:
# PHP Application
php-app:
build:
context: ./app
dockerfile: Dockerfile
container_name: hello-world-php
restart: unless-stopped
environment:
- APP_ENV=${APP_ENV:-development}
- DB_HOST=${DB_HOST:-mysql}
- DB_NAME=${DB_NAME:-hello_world}
- DB_USER=${DB_USER:-app_user}
- DB_PASSWORD=${DB_PASSWORD}
volumes:
- ./app:/var/www/html
- php_logs:/var/log
networks:
- app-network
depends_on:
mysql:
condition: service_healthy
healthcheck:
test: ["CMD", "php", "-f", "/var/www/html/index.php"]
interval: 30s
timeout: 10s
retries: 3
start_period: 40s
# Nginx Reverse Proxy
nginx:
build:
context: .
dockerfile: ./nginx/Dockerfile
container_name: hello-world-nginx
restart: unless-stopped
ports:
- "${APP_PORT:-8080}:80"
volumes:
- ./app:/var/www/html:ro
- nginx_logs:/var/log/nginx
networks:
- app-network
depends_on:
php-app:
condition: service_healthy
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost/health"]
interval: 30s
timeout: 10s
retries: 3
start_period: 40s
# MySQL Database
mysql:
image: mysql:8.0
container_name: hello-world-mysql
restart: unless-stopped
environment:
- MYSQL_ROOT_PASSWORD=${MYSQL_ROOT_PASSWORD}
- MYSQL_DATABASE=${DB_NAME:-hello_world}
- MYSQL_USER=${DB_USER:-app_user}
- MYSQL_PASSWORD=${DB_PASSWORD}
volumes:
- mysql_data:/var/lib/mysql
- mysql_logs:/var/log/mysql
- ./mysql/init.sql:/docker-entrypoint-initdb.d/init.sql:ro
networks:
- app-network
healthcheck:
test: ["CMD", "mysqladmin", "ping", "-h", "localhost", "-u", "root", "-p${MYSQL_ROOT_PASSWORD}"]
interval: 30s
timeout: 10s
retries: 5
start_period: 60s
# Database Administration (optional)
phpmyadmin:
image: phpmyadmin/phpmyadmin:latest
container_name: hello-world-phpmyadmin
restart: unless-stopped
environment:
- PMA_HOST=mysql
- PMA_USER=root
- PMA_PASSWORD=${MYSQL_ROOT_PASSWORD}
ports:
- "${PHPMYADMIN_PORT:-8081}:80"
networks:
- app-network
depends_on:
mysql:
condition: service_healthy
# Networks
networks:
app-network:
driver: bridge
ipam:
config:
- subnet: 172.20.0.0/16
# Volumes
volumes:
mysql_data:
driver: local
mysql_logs:
driver: local
nginx_logs:
driver: local
php_logs:
driver: local