-
Notifications
You must be signed in to change notification settings - Fork 0
/
compose.yaml
executable file
·205 lines (189 loc) · 6.39 KB
/
compose.yaml
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
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
services:
# Node.js - Vite Frontend Development
# https://github.com/nodejs/docker-node/tree/cd41dbe222da1ce72d61d8fbaa06ac79316ac6d5/16
frontend:
image: node:lts
restart: unless-stopped
user: "1000:1000"
working_dir: /var/www/frontend
stop_grace_period: 1s
tty: true
env_file: &env
- ./craftcms/.env
# missing package lock? -> full install
# missing node_modules? -> clean install (ci)
command: >
bash -c "[ ! -f package-lock.json ] && npm install;
[ ! -d node_modules/vite ] && npm ci;
npm run dev"
ports:
- 3000:3000
volumes:
- ./frontend:/var/www/frontend:delegated
- ./craftcms/templates:/var/www/craftcms/templates:ro
- ./craftcms/modules:/var/www/craftcms/modules:ro
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:3000/js/app.js"]
interval: 5s
timeout: 5s
retries: 100
# MySQL - Persistent Database Storage
# https://hub.docker.com/_/mysql
mysql:
image: mysql/mysql-server:8.0
restart: unless-stopped
command: --default-authentication-plugin=mysql_native_password
env_file:
*env
environment:
MYSQL_ROOT_PASSWORD: secret
ports:
- 3306:3306
volumes:
- mysql_data:/var/lib/mysql
- ./etc/database-seed:/docker-entrypoint-initdb.d
healthcheck:
test: "/usr/bin/mysql --user=root --password=$$MYSQL_ROOT_PASSWORD --execute \"SHOW DATABASES;\""
start_period: 3s
interval: 3s
timeout: 3s
retries: 20
# Composer - PHP Package & Dependency Management
# https://github.com/composer/docker
composer:
image: composer
command: "composer install --verbose --no-progress --optimize-autoloader --no-interaction"
tty: true
user: "1000:1000"
volumes:
- ./craftcms:/app
depends_on:
mysql:
condition: service_healthy
# Craft CMS - Migrate, Update, Clear Caches (ends once complete)
# https://github.com/simplicateca/docker-php-fpm
migrations: &craft
image: simplicateca/php-fpm:8.2
user: "1000:1000"
working_dir: /app
env_file:
*env
# test craft installed. clear caches.
# update project config. do migrations.
command: >
bash -c "./craft install/check &&
./craft setup/keys &&
./craft clear-caches/all --interactive=0 &&
./craft up --interactive=0"
volumes:
- ./craftcms:/app:cached
- ./frontend/public/static:/app/web/static:ro
- ./etc/php/php.ini:/usr/local/etc/php/conf.d/php.ini
depends_on:
composer:
condition: service_completed_successfully
mysql:
condition: service_healthy
redis:
condition: service_started
# Craft CMS - Primary PHP-FPM Container
# https://github.com/simplicateca/docker-php-fpm
php:
<<: *craft
restart: unless-stopped
command: "php-fpm"
depends_on:
migrations:
condition: service_completed_successfully
# Craft CMS - Queue Listerer / Runner
# https://craftcms.com/docs/5.x/extend/queue-jobs.html
queue:
<<: *craft
restart: unless-stopped
working_dir: /app
command: "./craft queue/listen 10"
tty: true
stop_grace_period: "1s"
depends_on:
migrations:
condition: service_completed_successfully
# Craft CMS - Nginx Webserver
# https://hub.docker.com/_/nginx
nginx:
image: nginx:1.23-alpine
restart: unless-stopped
env_file:
*env
ports:
- 8000:80
volumes:
- ./craftcms/web/index.php:/app/web/index.php:ro
- ./frontend/public/static:/app/web/static:ro
- ./etc/nginx/docker-config.conf:/etc/nginx/conf.d/craft.conf:ro
depends_on:
mysql:
condition: service_healthy
php:
condition: service_started
redis:
condition: service_started
# Redis - Session Storage
# https://hub.docker.com/_/redis
redis:
image: redis:5-alpine
ports:
- 6379:6379
# Status Banner - Welcome message on successful compose up
# https://hub.docker.com/_/busybox
status:
image: busybox
command: "sh -c 'sleep 3 && /bin/sh /home/banner.sh'"
env_file:
*env
volumes:
- ./etc/banner.sh:/home/banner.sh
depends_on:
nginx:
condition: service_started
frontend:
condition: service_healthy
## Reinstall Craft CMS
## ---------------------------------------------------------------
## Usage:
## docker compose exec php app/craft db/backup
## docker compose down -v
## docker compose up --profile install
## ---------------------------------------------------------------
## NOTE: This will **DELETE** existing Craft CMS SQL database.
## ---------------------------------------------------------------
install: &craft
image: simplicateca/php-fpm:8.2
profiles: [install]
user: "1000:1000"
working_dir: /app
env_file:
*env
command: >
bash -c "./craft install --email='craft@example.com' --password='letmein' --site-name='Craft CMS' --site-url='http://localhost:8000'"
volumes:
- ./craftcms:/app:cached
- ./frontend/public/static:/app/web/static:ro
- ./etc/php/php.ini:/usr/local/etc/php/conf.d/php.ini
depends_on:
composer:
condition: service_completed_successfully
mysql:
condition: service_healthy
redis:
condition: service_started
# Adminer / PhpMyAdmin - Database Management (Debug Profile)
adminer:
image: adminer
profiles: [debug]
depends_on:
mysql:
condition: service_healthy
ports:
- 8080:8080
volumes:
mysql_data: