Repository navigation
Expand file tree
/
Copy pathdocker-compose.yml
More file actions
121 lines (116 loc) · 3.78 KB
/
Copy pathdocker-compose.yml
File metadata and controls
121 lines (116 loc) · 3.78 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
# Tainacan local development stack.
#
# Three containers run by default: db, wordpress (php-fpm) and nginx. The
# `builder` service is profile-gated and only runs for `make assets` and
# `make watch`.
#
# WordPress core lives in a named volume. The only host directory exposed is the
# Tainacan plugin source, mounted read-only for the web tier so WordPress can
# never write generated files back into that repository. The builder is the only
# service with write access, and it is not reachable over HTTP.
services:
db:
image: mariadb:11
restart: unless-stopped
command:
- --character-set-server=utf8mb4
- --collation-server=utf8mb4_unicode_ci
environment:
MARIADB_DATABASE: ${DB_NAME:-tainacan}
MARIADB_USER: ${DB_USER:-tainacan}
MARIADB_PASSWORD: ${DB_PASSWORD:-tainacan}
MARIADB_ROOT_PASSWORD: ${DB_ROOT_PASSWORD:-tainacan}
ports:
- "${DB_PORT:-3306}:3306"
volumes:
- db_data:/var/lib/mysql
healthcheck:
test: ["CMD", "healthcheck.sh", "--connect", "--innodb_initialized"]
interval: 10s
timeout: 5s
retries: 10
start_period: 20s
wordpress:
build:
context: ./dockerfiles/wordpress
restart: unless-stopped
depends_on:
db:
condition: service_healthy
environment:
WORDPRESS_DB_HOST: db:3306
WORDPRESS_DB_NAME: ${DB_NAME:-tainacan}
WORDPRESS_DB_USER: ${DB_USER:-tainacan}
WORDPRESS_DB_PASSWORD: ${DB_PASSWORD:-tainacan}
WORDPRESS_TABLE_PREFIX: ${DB_PREFIX:-wp_}
WORDPRESS_DEBUG: ${WP_DEBUG:-1}
volumes:
- wordpress_data:/var/www/html
# Read-only: WordPress must never write into the Tainacan repository.
# WP-CLI also runs in this container (`make wp`), as uid 33.
- type: bind
source: ${TAINACAN_PLUGIN_PATH:-../tainacan}/src
target: /var/www/html/wp-content/plugins/tainacan
read_only: true
nginx:
image: nginx:1.27-alpine
restart: unless-stopped
depends_on:
- wordpress
ports:
- "${WP_PORT:-8080}:80"
volumes:
- wordpress_data:/var/www/html:ro
- type: bind
source: ${TAINACAN_PLUGIN_PATH:-../tainacan}/src
target: /var/www/html/wp-content/plugins/tainacan
read_only: true
- ./dockerfiles/nginx/default.conf:/etc/nginx/conf.d/default.conf:ro
healthcheck:
test: ["CMD-SHELL", "wget -q -O /dev/null http://127.0.0.1/ || exit 1"]
interval: 10s
timeout: 5s
retries: 6
start_period: 20s
# Asset builder and watcher, and the WordPress test runner. It is the only
# service with write access to the plugin source. Profile-gated, so it never
# starts with `make up`.
builder:
build:
context: ./dockerfiles/builder
profiles: ["watch"]
working_dir: /repo
volumes:
- type: bind
source: ${TAINACAN_PLUGIN_PATH:-../tainacan}
target: /repo
# node_modules stays off the macOS bind mount for I/O speed.
- tainacan_node_modules:/repo/node_modules
# WordPress test suite download cache, used by `make test`.
- wp_tests:/tmp/wp-tests
command:
- sh
- -lc
- |
set -e
./build.sh
touch /tmp/plugin.stamp
echo "Watching tainacan/src for changes (polling every 2s)..."
while :; do
sleep 2
plugin_changed=$(find src -type f -newer /tmp/plugin.stamp \
-not -path 'src/assets/js/*' \
-not -path 'src/assets/css/*' \
-not -path 'src/vendor/*' \
-print -quit)
if [ -n "$$plugin_changed" ]; then
touch /tmp/plugin.stamp
echo "Change detected in tainacan/src; rebuilding plugin assets"
./build.sh
fi
done
volumes:
db_data:
wordpress_data:
tainacan_node_modules:
wp_tests: