Repository navigation
Expand file tree
/
Copy pathcompose.production.yaml
More file actions
106 lines (98 loc) · 3.3 KB
/
Copy pathcompose.production.yaml
File metadata and controls
106 lines (98 loc) · 3.3 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
# Production compose — the recipe published for self-hosters (M20.2 §3.2),
# and the one our own box runs. Sail's compose.yaml is dev-only.
#
# docker compose -f compose.production.yaml up -d
#
# Expects a host .env alongside this file (never baked into the image),
# TLS certs under /etc/letsencrypt, and an ACME webroot at ./certbot-webroot.
# See docs/ops/get-live/ for the full walkthrough.
x-logging: &logging
driver: json-file
options:
max-size: "10m"
max-file: "3"
x-app: &app
image: ghcr.io/n8bar/cryptozing-app:${CZ_TAG:-latest}
restart: unless-stopped
# A real init as PID 1. schedule:work and queue:work are not inits: children
# that finish get reparented to them and are never reaped, and the zombies
# count against the container user's process limit on the host.
init: true
env_file: .env
logging: *logging
volumes:
- ./storage:/var/www/html/storage
depends_on:
db:
condition: service_healthy
services:
app:
<<: *app
volumes:
- ./storage:/var/www/html/storage
- app-public:/shared/public
web:
image: nginx:1.27-alpine
restart: unless-stopped
# Only the template variable — no app secrets in this container.
environment:
CZ_SERVER_NAME: ${CZ_SERVER_NAME}
logging: *logging
ports:
- "80:80"
- "443:443"
volumes:
- ./docker/production/nginx/templates:/etc/nginx/templates:ro
- app-public:/var/www/html/public:ro
- /etc/letsencrypt:/etc/letsencrypt:ro
- ./certbot-webroot:/var/www/certbot:ro
depends_on:
- app
db:
image: mysql:8.0
restart: unless-stopped
logging: *logging
# Internal network only — no published ports.
environment:
MYSQL_DATABASE: ${DB_DATABASE}
MYSQL_USER: ${DB_USERNAME}
MYSQL_PASSWORD: ${DB_PASSWORD}
MYSQL_ROOT_PASSWORD: ${DB_ROOT_PASSWORD}
volumes:
- dbdata:/var/lib/mysql
- ./docker/production/mysql/prod.cnf:/etc/mysql/conf.d/prod.cnf:ro
healthcheck:
test: ["CMD-SHELL", "mysqladmin ping -h127.0.0.1 -u\"$$MYSQL_USER\" -p\"$$MYSQL_PASSWORD\" --silent"]
interval: 15s
timeout: 5s
retries: 5
start_period: 60s
# Both workers run the app image without PHP-FPM, so the image's FPM ping
# cannot speak for them (#153). Each refreshes a heartbeat as its loop turns
# and answers on the age of it — a wedged worker goes quiet while its process
# stays up, which is the failure the restart policy alone never catches.
queue:
<<: *app
command: php artisan queue:work --tries=3 --timeout=90 --max-time=3600
healthcheck:
# The loop turns every few seconds, idle or not.
test: ["CMD", "php", "/var/www/html/docker/production/worker-healthcheck.php", "queue", "60"]
interval: 30s
timeout: 5s
retries: 3
start_period: 30s
# Also covers the payment watcher: wallet:watch-payments runs as a
# per-minute scheduled command, not an always-on process (§2.3.1.2).
scheduler:
<<: *app
command: php artisan schedule:work
healthcheck:
# One tick a minute, and the first waits for the top of the next one.
test: ["CMD", "php", "/var/www/html/docker/production/worker-healthcheck.php", "scheduler", "180"]
interval: 60s
timeout: 10s
retries: 3
start_period: 120s
volumes:
dbdata:
app-public: