forked from ideasonpurpose/docker-wordpress-dev
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocker-compose.yml
More file actions
291 lines (272 loc) · 10.1 KB
/
docker-compose.yml
File metadata and controls
291 lines (272 loc) · 10.1 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
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
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
services:
# Primary database for the local WordPress development environment.
# Image from: https://hub.docker.com/_/mariadb
db:
image: &db_img mariadb:11.1.2
restart: always
volumes:
- db_data:/var/lib/mysql
- ./_db:/docker-entrypoint-initdb.d
# - ./_log/mysql:/var/log/mysql
environment:
MYSQL_ALLOW_EMPTY_PASSWORD: 1
MYSQL_DATABASE: wordpress
MYSQL_USER: wordpress
MYSQL_PASSWORD: wordpress
# command: >
# --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci
# Ideas On Purpose's local WordPress development environment.
# Update image version with `docker run ideasonpurpose/wordpress init`
# Project info: https://github.com/ideasonpurpose/docker-wordpress-dev
wordpress:
depends_on:
- db
# image: &wp_img ideasonpurpose/wordpress:dev
image: &wp_img ideasonpurpose/wordpress:6.6.2
restart: always
volumes:
- wp_data:/var/www/html
- ./wp-content/themes/${npm_package_name:-ioptheme}:/var/www/html/wp-content/themes/${npm_package_name:-ioptheme}
- ./wp-content/plugins:/var/www/html/wp-content/plugins
- ./wp-content/uploads:/var/www/html/wp-content/uploads
- ${IOP_DEV_PLUGIN_1:-/tmp/null:/tmp/IOP_DEV_PLUGIN_1}
- ${IOP_DEV_PLUGIN_2:-/tmp/null:/tmp/IOP_DEV_PLUGIN_2}
- ${IOP_DEV_PLUGIN_3:-/tmp/null:/tmp/IOP_DEV_PLUGIN_3}
- ${IOP_DEV_PLUGIN_4:-/tmp/null:/tmp/IOP_DEV_PLUGIN_4}
- ${IOP_DEV_PLUGIN_5:-/tmp/null:/tmp/IOP_DEV_PLUGIN_5}
- ${IOP_DEV_PLUGIN_6:-/tmp/null:/tmp/IOP_DEV_PLUGIN_6}
- ${IOP_DEV_PLUGIN_7:-/tmp/null:/tmp/IOP_DEV_PLUGIN_7}
- ${IOP_DEV_PLUGIN_8:-/tmp/null:/tmp/IOP_DEV_PLUGIN_8}
- ./webpack/xdebug:/tmp/xdebug
# Publish port 80 to an ephemeral host port to prepare for future local build tools
ports:
- "80"
# Internally expose port 9003 for XDebug and profiling
expose:
- 9003
# Link external plugin projects by defining host:container path pairs in .env
environment:
IOP_DEV_PLUGIN_1:
IOP_DEV_PLUGIN_2:
IOP_DEV_PLUGIN_3:
IOP_DEV_PLUGIN_4:
IOP_DEV_PLUGIN_5:
IOP_DEV_PLUGIN_6:
IOP_DEV_PLUGIN_7:
IOP_DEV_PLUGIN_8:
# Apache will throw errors for any ulimit value below 8192
# NOTE THAT THIS MIGHT BE MORE THAN THE SYSTEM OFFERS
# TODO: Still true?
ulimits:
nofile: 8192
# Ideas On Purpose's development toolchain
# Image from: https://hub.docker.com/r/ideasonpurpose/docker-build
tools:
# image: ideasonpurpose/docker-build:dev
image: ideasonpurpose/docker-build:0.17.1
user: "${UID:-1000}:${GID:-1000}"
depends_on:
- wordpress
volumes:
- .:/usr/src/site/
ports:
- "${npm_config_port:-8080}:8080"
environment:
PORT: ${npm_config_port:-8080}
entrypoint: npm run
command: start
# Utility service for running composer commands
# Image from: https://hub.docker.com/_/composer
composer:
image: composer:2.6
profiles: ["utility"]
user: "${UID:-1000}:${GID:-1000}"
environment:
COMPOSER_HOME: /.composer
volumes:
- ./:/app
- ~/.composer:/.composer
command: install
# Utility service which exposes wp-cli. Useful for testing pre-releases
# Update image version with `docker run ideasonpurpose/wordpress init`
# Project info: https://github.com/ideasonpurpose/docker-wordpress-dev
wp-cli:
depends_on:
- db
- wordpress
image: *wp_img
profiles: ["utility"]
user: www-data
volumes:
- wp_data:/var/www/html
- ./wp-content/themes/${npm_package_name:-ioptheme}:/var/www/html/wp-content/themes/${npm_package_name:-ioptheme}
- ./wp-content/plugins:/var/www/html/wp-content/plugins
- ./wp-content/uploads:/var/www/html/wp-content/uploads
environment:
- WP_CLI_CACHE_DIR=/tmp/wp-cli
- WP_CLI_DISABLE_AUTO_CHECK_UPDATE=true
command: wp theme activate ${npm_package_name:-ioptheme}
# Runs phpMyAdmin on port 8002
# Image from: https://hub.docker.com/_/phpmyadmin
phpmyadmin:
image: phpmyadmin:5.2.1-apache
profiles: ["utility"]
ports:
- "${npm_config_port:-8002}:80"
depends_on:
- db
environment:
PMA_USER: root
PMA_PASSWORD: ~
UPLOAD_LIMIT: 1G
command: |
bash -c 'echo &&
echo -e "🛠 \033[33mStarting phpMyAdmin at\033[0m \033[36mhttp://localhost:${npm_config_port:-8002}\033[0m" &&
echo &&
/docker-entrypoint.sh apache2-foreground'
# XDebug profile viewer at http://localhost:9001 (change port with --port=xxxx)
# Enable profiling by appending `?XDEBUG_PROFILE=1` to any request
# https://hub.docker.com/r/wodby/webgrind
webgrind:
image: wodby/webgrind:1.9
profiles: ["utility"]
user: "${UID:-1000}:${GID:-1000}"
ports:
- "${npm_config_port:-9004}:8080"
depends_on:
- wordpress
volumes:
- ./webpack/xdebug:/tmp
environment:
WEBGRIND_DEFAULT_TIMEZONE: America/New_York
command: |
bash -c 'echo &&
echo -e "🔍 \033[33mStarting WebGrind server at\033[0m \033[36mhttp://localhost:${npm_config_port:-9004}\033[0m" &&
echo -e "⏱️ Profile any request by adding \033[1;35m?XDEBUG_PROFILE=1\033[0m to the url" &&
echo &&
php -S 0.0.0.0:8080 index.php
'
# Dumps the current database to _db/theme-YYYY-MM-DDTHHMMSS.sql.gz
db-dump:
image: *db_img
profiles: ["utility"]
depends_on:
- db
volumes:
- ./_db:/usr/src
environment:
MYSQL_DATABASE: wordpress
OWNER_GROUP: "${UID:-1000}:${GID:-1000}"
# NOTE: The datbase dumpfile will include these CREATE/USE commands:
# CREATE DATABASE `wordpress`;
# USE `wordpress`;
# to drop those lines, remove "--databases" from the mariadb-dump command
command: |
bash -c 'for i in {1..10}
do echo -e "⏳ \033[33mWaiting for MariaDB server...\033[0m" &&
mariadb -s -h db -e "exit" && break || sleep 3
done &&
sleep 2 &&
echo -e "✔️ \033[32mConnected to MariaDB\033[0m" &&
export DUMPFILE="/usr/src/'${npm_package_name:-dumpfile}'-$$(date +%FT%H%M%S).sql" &&
echo $${DUMPFILE} &&
mariadb-dump -hdb --databases $${MYSQL_DATABASE} > "$${DUMPFILE}" &&
gzip "$${DUMPFILE}" &&
chown -R $${OWNER_GROUP} /usr/src &&
echo "Successfully dumped database to \"$${DUMPFILE}.gz\""'
# Reloads the database from the first found *.sql dumpfile in _db
db-reload:
image: *db_img
profiles: ["utility"]
depends_on:
- db
volumes:
- ./_db:/usr/src/dumpfiles
environment:
MYSQL_DATABASE: wordpress
command: |
bash -c 'for i in {1..10}
do echo -e "⏳ \033[33mWaiting for MariaDB server...\033[0m" &&
mariadb -s -h db -e "exit" && break || sleep 3
done &&
sleep 2 &&
echo -e "✔️ \033[32mConnected to MariaDB\033[0m" &&
mariadb-admin -hdb -v -f drop $${MYSQL_DATABASE} &&
mariadb-admin -hdb -v -f create $${MYSQL_DATABASE} &&
echo Database \"$${MYSQL_DATABASE}\" created &&
echo Reloading database from dumpfile &&
mariadb -hdb $${MYSQL_DATABASE} < $$(ls /usr/src/dumpfiles/*.sql | tail -n1)'
# Activates the theme directly in the database
theme-activate:
image: *db_img
profiles: ["utility"]
depends_on:
- db
volumes:
- ./_db:/usr/src/dumpfiles
environment:
MYSQL_DATABASE: wordpress
command: |
bash -c 'for i in {1..10}
do echo -e "⏳ \033[33mWaiting for DB server...\033[0m" &&
mariadb -s -h db -e "exit" && break || sleep 3
done &&
sleep 2 &&
echo -e "✔️ \033[32mConnected to MariaDB\033[0m" &&
if [[ $$(mariadb -s -h db $${MYSQL_DATABASE} -e "SHOW TABLES LIKE \"wp_options\"") ]]
then
echo -e "🎨 \033[36mActivating theme \033[0m\033[1m${npm_package_name:-ioptheme}\033[0m"
mariadb -h db $${MYSQL_DATABASE} \
-e "UPDATE wp_options \
SET option_value = \"'${npm_package_name:-ioptheme}'\" \
WHERE option_name in (\"template\",\"stylesheet\")"
else
echo -e "Unable to activate theme: \033[31m'\'wp_options\'' table does not exist.\033[0m"
echo "To recreate an existing site, copy the site'\''s MariaDB dumpfile into _db"
echo If this project is starting from an empty database, you can ignore this message.
fi'
# Repairs permissions for known project files and directories
repair-permissions:
image: *wp_img
profiles: ["utility"]
volumes:
- .:/usr/src/site
environment:
OWNER_GROUP: "${UID:-1000}:${GID:-1000}"
entrypoint: /usr/local/bin/permissions.sh
# Locally mirror remote sites by pulling the database, plugins and uploads
# Remote connections are configured in the project's .env file
pull:
image: *wp_img
profiles: ["utility"]
volumes:
- .:/usr/src/site
entrypoint: |
/usr/local/bin/pull.sh
environment:
OWNER_GROUP: "${UID:-1000}:${GID:-1000}"
SSH_KEY_PATH:
SSH_LOGIN:
SSH_USER:
SSH_PORT:
SSH_WP_CONTENT_DIR:
secrets:
- SSH_KEY
# Run the init script from ideasonpurpose/wordpress:latest (intentionally "latest")
# to refresh tooling and bring the project inline with our boilerplate
# Project info: https://github.com/ideasonpurpose/docker-wordpress-dev
refresh:
# image: ideasonpurpose/wordpress:dev
image: ideasonpurpose/wordpress:latest
profiles: ["utility"]
volumes:
- .:/usr/src/site
command: init
secrets:
SSH_KEY:
file: ${SSH_KEY_PATH:-~/.ssh/your_ssh_private_key}
volumes:
db_data:
name: ${npm_package_name:-ioptheme}_db
wp_data:
name: ${npm_package_name:-ioptheme}_wp