-
Notifications
You must be signed in to change notification settings - Fork 5
/
slic-stack.yml
205 lines (197 loc) · 9.12 KB
/
slic-stack.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
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
# docker compose configuration file used to run cross-activation tests.
networks:
slic:
volumes:
function-mocker-cache:
services:
db:
image: mariadb:10.7.8
networks:
- slic
ports:
- "${SLIC_DB_LOCALHOST_PORT:-9006}:3306"
environment:
MYSQL_DATABASE: test
MYSQL_ROOT_PASSWORD: ${MYSQL_ROOT_PASSWORD:-root}
healthcheck: # The `test` db should exist.
test: mysqlshow -u root -p${MYSQL_ROOT_PASSWORD:-root} test
start_period: 5s
interval: 1s
timeout: 3s
retries: 30
tmpfs:
- /var/lib/mysql
redis:
image: redis:7.0.10
networks:
- slic
ports:
- "${SLIC_REDIS_LOCALHOST_PORT:-8379}:6379"
healthcheck: # It should reply PONG to PING
test: redis-cli ping | grep PONG
start_period: 2s
interval: 1s
timeout: 3s
retries: 30
tmpfs:
- /data
wordpress:
image: ghcr.io/stellarwp/slic-wordpress-php${SLIC_PHP_VERSION}:${SLIC_VERSION}
networks:
slic:
aliases: # Allow reaching the site at `http://wordpress.test` and other domains that might be used in testing.
- wordpress.test
- www.wordpress.test
- test1.wordpress.test
- test2.wordpress.test
- test3.wordpress.test
depends_on:
db:
condition: service_healthy
redis:
condition: service_healthy
# Run the container as the host user and group.
# Apache will run as the same user and permission issues with WordPress generated files should not arise.
user: "${SLIC_UID:-}:${SLIC_GID:-}"
sysctls:
# Allow any user to bind ports <= 1024.
# This is required as we're running the container as the host user and that user might not be in the root
# wheel in the container.
net.ipv4.ip_unprivileged_port_start: 0
ports:
# Allow reaching the site at `http://localhost:8888`.
# The port, in the container, is not the default `80` to allow non root users to bind (listen) to it.
- "${WORDPRESS_HTTP_PORT:-8888}:80"
environment:
COMPOSER_CACHE_DIR: "/composer-cache"
WORDPRESS_DB_USER: root
WORDPRESS_DB_PASSWORD: password
# This db is created by the db container at startup, no need to create it.
WORDPRESS_DB_NAME: test
WORDPRESS_DB_HOST: db
WORDPRESS_DEBUG: 1
# Pull plugins from the `/plugins` directory to allow debugging the files we're working on.
WORDPRESS_CONFIG_EXTRA: |
$$scheme = empty( $$_SERVER['HTTPS'] ) ? 'http' : 'https';
$$url = isset( $$_SERVER['HTTP_HOST'] ) ? $$_SERVER['HTTP_HOST'] : 'wordpress.test';
define( 'WP_HOME', $$scheme . '://' . $$url );
define( 'WP_SITEURL', $$scheme . '://' . $$url );
define( 'WP_REDIS_HOST', 'redis' );
define( 'WP_REDIS_PORT', 6379 );
define( 'TRIBE_NO_FREEMIUS', true );
define( 'WP_DEBUG_DISPLAY', true );
define( 'WP_DEBUG_LOG', true );
define( 'DISABLE_WP_CRON', ${SLIC_DISABLE_WP_CRON:-true} );
define( 'WP_HTTP_BLOCK_EXTERNAL', ${SLIC_WP_HTTP_BLOCK_EXTERNAL:-true} );
define( 'WP_AUTO_UPDATE_CORE', ${SLIC_WP_AUTO_UPDATE_CORE:-false} );
define( 'AUTOMATIC_UPDATER_DISABLED', ${SLIC_AUTOMATIC_UPDATER_DISABLED:-true} );
# Configure this to debug the tests with XDebug.
# Map the `_wordpress` directory to `/var/www/html' directory in your IDE of choice.
# Map the `_plugins` directory to `/plugins` directory in your IDE of choice.
PHP_IDE_CONFIG: "serverName=${XDK:-slic}"
# The `remote_host` is set to `host.docker.internal` that will resolve to the host machine IP address, from
# within the container, on macOS and Windows.
# On Linux set the host machine IP address before calling the stack:
# XDH=$(ip route | grep docker0 | awk '{print $9}') docker compose ...
XDEBUG_CONFIG: "idekey=${XDK:-slic} remote_enable=${XDE:-1} remote_host=${XDH:-host.docker.internal} remote_port=${XDP:-9001} client_host=${XDH:-host.docker.internal} client_port=${XDP:-9001}"
# Whether to disable the XDebug extension in the Codeception container completely or not.
XDEBUG_DISABLE: "${XDEBUG_DISABLE:-0}"
volumes:
# Paths are relative to the directory that contains this file, NOT the current working directory.
- ${SLIC_WP_DIR}:/var/www/html
- ${SLIC_PLUGINS_DIR}:/var/www/html/wp-content/plugins
- ${SLIC_THEMES_DIR}:/var/www/html/wp-content/themes
- ${COMPOSER_CACHE_DIR:-./.cache}:/composer-cache
- ./containers/wordpress/php.ini:/usr/local/etc/php/conf.d/zz-docker.ini
healthcheck: # Apache service should be running correctly.
test: service apache2 status
start_period: 5s
interval: 1s
timeout: 3s
retries: 30
extra_hosts:
# Set as host=host.docker.internal in src/slic.php on Linux for XDebug.
- "${host:-host}:host-gateway"
chrome:
image: ${SLIC_CHROME_CONTAINER:-selenium/standalone-chrome:3.141.59}
networks:
- slic
depends_on:
wordpress:
condition: service_healthy
healthcheck: # It should reply with a 200 status code to a request to the status endpoint.
test: curl -f http://localhost:4444/wd/hub/status
start_period: 5s
interval: 1s
timeout: 3s
retries: 30
shm_size: "${SLIC_CHROME_CONTAINER_SHM_SIZE:-256m}"
slic:
image: ghcr.io/stellarwp/slic-php${SLIC_PHP_VERSION}:${SLIC_VERSION}
networks:
- slic
user: "${SLIC_UID:-}:${SLIC_GID:-}"
depends_on:
db:
condition: service_healthy
chrome:
condition: service_healthy
wordpress:
condition: service_healthy
environment:
COMPOSER_AUTH: "${COMPOSER_AUTH:-}"
COMPOSER_CACHE_DIR: "/composer-cache"
# Set these values to allow the container to look wordpress up.
WORDPRESS_DB_USER: root
WORDPRESS_DB_PASSWORD: password
WORDPRESS_DB_NAME: test
WORDPRESS_DB_HOST: db
WORDPRESS_URL: http://wordpress.test
# Configure this to debug the tests with XDebug.
# Map the `_wordpress` directory to `/var/www/html' directory in your IDE of choice.
# Map the `_plugins` directory to `/plugins' directory in your IDE of choice.
PHP_IDE_CONFIG: "serverName=${XDK:-slic}"
# The `remote_host` is set to `host.docker.internal` that will resolve to the host machine IP address, from
# within the container, on macOS and Windows.
# On Linux set the host machine IP address before calling the stack:
# XDH=$(ip route | grep docker0 | awk '{print $9}') docker compose ...
XDEBUG_CONFIG: "idekey=${XDK:-slic} remote_enable=${XDE:-1} remote_host=${XDH:-host.docker.internal} remote_port=${XDP:-9001} client_host=${XDH:-host.docker.internal} client_port=${XDP:-9001}"
# Move to the target directory before running the command from the plugins directory.
CODECEPTION_PROJECT_DIR: /var/www/html/wp-content/plugins/${SLIC_CURRENT_PROJECT:-test}/${SLIC_CURRENT_PROJECT_SUBDIR:-}
# When running the container in shell mode (using the slic `shell` command), then use this CC configuration.
CODECEPTION_SHELL_CONFIG: "-c codeception.slic.yml"
# Whether to disable the XDebug extension in the Codeception container completely or not.
XDEBUG_DISABLE: "${XDEBUG_DISABLE:-0}"
# Declare that we are in a slic context so plugins can set custom test configs.
STELLAR_SLIC: 1
# Backwards compatibility
TRIBE_TRIC: 1
# If we're in CI context, then pass it through.
CI: "${CI:-}"
# Let's set the lines and columns number explicitly to have the shell mirror the current one.
LINES: "${LINES:-24}"
COLUMNS: "${COLUMNS:-80}"
# Explicitly set the env var that will define the Function Mocker cache path: it will be picked up by the config file.
FUNCTION_MOCKER_CACHE_PATH: "/cache"
# Explicitly set the path to the Playwright browsers cache to make sure it will be the same for all users.
PLAYWRIGHT_BROWSERS_PATH: "/home/slic/.cache/ms-playwright"
volumes:
# Paths are relative to the directory that contains this file, NOT the current working directory.
# Share the WordPress core installation files in the `_wordpress` directory.
- ${SLIC_WP_DIR}:/var/www/html
# Share the plugins in the `/var/www/hmtl/wp-content/plugins` directory.
- ${SLIC_PLUGINS_DIR}:/var/www/html/wp-content/plugins
- ${SLIC_THEMES_DIR}:/var/www/html/wp-content/themes
# In some plugins we use function-mocker and set it up to cache in `/tmp/function-mocker`.
# To avoid a long re-caching on each run, let's cache in a docker volume, caching on the host
# filesystem would be a worse cure than the disease.
# The volume is bound to the `a+rwx` directory the `slic` image provides to avoid file mode issues.
- function-mocker-cache:/cache
- ${COMPOSER_CACHE_DIR:-./.cache}:/composer-cache
# Scripts volume
- ${SLIC_SCRIPTS}:/slic-scripts
# Configurable php.ini volume
- ./containers/slic/php.ini:/usr/local/etc/php/conf.d/zz-docker.ini
extra_hosts:
# Set as host=host.docker.internal in src/slic.php on Linux for XDebug.
- "${host:-host}:host-gateway"