-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathdocker-compose.yml
172 lines (162 loc) · 5.96 KB
/
docker-compose.yml
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
x-wordpress-configuration-env: &wordpress-configuration-env
WORDPRESS_PLUGIN_LIST: "maintenance redis-cache"
WORDPRESS_REDIS_HOST: redis
WORDPRESS_CACHE: 1
WORDPRESS_CACHE_KEY_SALT: 'Wp-'
WORDPRESS_TABLE_PREFIX: 'wp_'
WORDPRESS_DEBUG: 0
DEFAULT_EMAIL: "[email protected]"
WORDPRESS_DB_USER: wordpress
WORDPRESS_DB_NAME: wordpress
WORDPRESS_DB_HOST: database
WORDPRESS_CONFIG_EXTRA: |
define('WP_AUTO_UPDATE_CORE', false);
define('WP_SITEURL', 'http://localhost');
define('WP_HOME', 'http://localhost');
define('WP_CACHE', true);
define('WP_CACHE_KEY_SALT', 'Wp-');
define('WP_REDIS_HOST', "cache");
define('DISABLE_WP_CRON', true);
$$_SERVER['HTTP_UPGRADE_INSECURE_REQUESTS'] = false;
# Required since nginx unit will not pass environment variables s6-envdir loads. wp-config.php has docker_getenv()
x-wordpress-secrets-files: &wordpress-secrets-files-env
WORDPRESS_AUTH_KEY_FILE: /run/secrets/wordpress_auth_key
WORDPRESS_SECURE_AUTH_KEY_FILE: /run/secrets/wordpress_secure_auth_key
WORDPRESS_LOGGED_IN_KEY_FILE: /run/secrets/wordpress_logged_in_key
WORDPRESS_NONCE_KEY_FILE: /run/secrets/wordpress_nonce_key
WORDPRESS_AUTH_SALT_FILE: /run/secrets/wordpress_auth_salt
WORDPRESS_SECURE_AUTH_SALT_FILE: /run/secrets/wordpress_secure_auth_salt
WORDPRESS_LOGGED_IN_SALT_FILE: /run/secrets/wordpress_logged_in_salt
WORDPRESS_NONCE_SALT_FILE: /run/secrets/wordpress_nonce_salt
WORDPRESS_DB_PASSWORD_FILE: /run/secrets/wordpress_db_password
x-wordpress-init-env: &wordpress-init-env
WORDPRESS_INIT_ENABLE: "true"
WORDPRESS_INIT_ADMIN_USER: admin
# WORDPRESS_INIT_ADMIN_PASSWORD is defined in secrets
WORDPRESS_INIT_ADMIN_EMAIL: [email protected]
WORDPRESS_INIT_SITE_TITLE: "Your Example Site"
WORDPRESS_INIT_SITE_URL: "http://localhost"
networks:
default:
secrets:
database_root_password:
file: ./.secrets/database_root_password.txt
wordpress_database_password:
file: ./.secrets/wordpress_database_password.txt
wordpress_db_password:
file: ./.secrets/wordpress_database_password.txt
wordpress_auth_key:
file: ./.secrets/wordpress_auth_key
wordpress_secure_auth_key:
file: ./.secrets/wordpress_secure_auth_key
wordpress_logged_in_key:
file: ./.secrets/wordpress_logged_in_key
wordpress_nonce_key:
file: ./.secrets/wordpress_nonce_key
wordpress_auth_salt:
file: ./.secrets/wordpress_auth_salt
wordpress_secure_auth_salt:
file: ./.secrets/wordpress_secure_auth_salt
wordpress_logged_in_salt:
file: ./.secrets/wordpress_logged_in_salt
wordpress_nonce_salt:
file: ./.secrets/wordpress_nonce_salt
wordpress_init_admin_password:
file: ./.secrets/wordpress_init_admin_password
services:
wordpress:
image: ghcr.io/n0rthernl1ghts/wordpress:6.6.2
deploy:
restart_policy:
condition: any
healthcheck: # See: src/wp-utils/healthcheck
test: [ "CMD", "/usr/local/bin/healthcheck" ]
interval: 30s
timeout: 5s
retries: 3
secrets:
- wordpress_db_password
- wordpress_auth_key
- wordpress_secure_auth_key
- wordpress_logged_in_key
- wordpress_nonce_key
- wordpress_auth_salt
- wordpress_secure_auth_salt
- wordpress_logged_in_salt
- wordpress_nonce_salt
- wordpress_init_admin_password
environment:
<<: [ *wordpress-configuration-env, *wordpress-secrets-files-env, *wordpress-init-env ]
CRON_ENABLED: "false"
labels: # This configures traefik - if you have it. You also need to make sure that this service is in the same network with Traefik instance
- "traefik.enable=true"
- "traefik.http.routers.${COMPOSE_PROJECT_NAME}-http.rule=Host(`example.com`)"
- "traefik.http.routers.${COMPOSE_PROJECT_NAME}-http.entrypoints=web"
- "traefik.http.routers.${COMPOSE_PROJECT_NAME}-https.tls=true"
- "traefik.http.routers.${COMPOSE_PROJECT_NAME}-https.tls.certresolver=le"
- "traefik.http.routers.${COMPOSE_PROJECT_NAME}-https.rule=Host(`example.com`)"
- "traefik.http.routers.${COMPOSE_PROJECT_NAME}-https.entrypoints=websecure"
- "traefik.http.services.${COMPOSE_PROJECT_NAME}.loadbalancer.server.port=80"
volumes:
- ./data/wordpress/wp-content:/var/www/html/wp-content
networks:
default:
# It's a good idea to have a separate service for the cron job
cron:
extends:
service: wordpress
image: ghcr.io/n0rthernl1ghts/wordpress-cron:6.6.2
deploy:
resources:
limits:
memory: 512M # Limit the memory for the cron job to 512 MB. This is a good practice to avoid memory leaks.
environment:
CRON_ENABLED: "true"
# Redis is optional, but it works really well for caching. If removed, please update x-wordpress-configuration-env
cache:
image: redis:alpine
init: true
healthcheck:
test: ["CMD", "/usr/local/bin/redis-cli", "PING"]
interval: 20s
timeout: 3s
retries: 3
deploy:
restart_policy:
condition: any
resources:
limits:
memory: 64M
networks:
default:
# Please update environment accordingly
database:
image: 'ghcr.io/n0rthernl1ghts/mariadb:10.11'
deploy:
replicas: 1
restart_policy:
condition: any
resources:
limits:
memory: 512M # Should be adjusted accordingly to the website size. 512MB is usually enough for small website
healthcheck:
test: ["CMD", "/usr/bin/healthcheck"]
interval: 30s
timeout: 20s
retries: 3
environment:
PUID: 1000
PGID: 1000
MARIADB_INIT_DATABASES: wordpress
MARIADB_INIT_USERS: wordpress
FILE__MARIADB_ROOT_PASSWORD: /run/secrets/database_root_password
FILE__MARIADB_USER_wordpress_PASSWORD: /run/secrets/wordpress_database_password
FORCE_CONFIG_OVERWRITE: 1
volumes:
- ./data/database/config:/config
- ./data/database/data:/var/lib/mysql
secrets:
- database_root_password
- wordpress_database_password
networks:
default: