Skip to content

Commit 903493b

Browse files
committed
Move the Memcached container into the Docker Compose config.
1 parent e999a8b commit 903493b

File tree

3 files changed

+19
-9
lines changed

3 files changed

+19
-9
lines changed

.github/workflows/phpunit-tests.yml

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ jobs:
4646
# - Installs Composer dependencies.
4747
# - Logs Docker debug information (about the Docker installation within the runner).
4848
# - Starts the WordPress Docker container.
49-
# - Starts the Memcached server after the Docker network has been created (if desired).
5049
# - Logs general debug information about the runner.
5150
# - Logs the running Docker containers.
5251
# - Logs debug information from inside the WordPress Docker container.
@@ -159,13 +158,6 @@ jobs:
159158
run: |
160159
npm run env:start
161160
162-
# The memcached server needs to start after the Docker network has been set up with `npm run env:start`.
163-
- name: Start the Memcached server.
164-
if: ${{ matrix.memcached }}
165-
run: |
166-
cp tests/phpunit/includes/object-cache.php src/wp-content/object-cache.php
167-
docker run --name memcached --net $(basename "$PWD")_wpdevnet -d memcached
168-
169161
- name: General debug information
170162
run: |
171163
npm --version

docker-compose.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,9 @@ services:
4949
- ./tools/local-env/php-config.ini:/usr/local/etc/php/conf.d/php-config.ini
5050
- ./:/var/www
5151

52+
# Copy or delete the Memcached dropin plugin file as appropriate.
53+
command: /bin/sh -c "if [ $LOCAL_PHP_MEMCACHED = true ]; then cp -n /var/www/tests/phpunit/includes/object-cache.php /var/www/src/wp-content/object-cache.php; else rm -f /var/www/src/wp-content/object-cache.php; fi && exec php-fpm"
54+
5255
depends_on:
5356
- mysql
5457

@@ -104,6 +107,18 @@ services:
104107
extra_hosts:
105108
- localhost:host-gateway
106109

110+
##
111+
# The Memcached container.
112+
##
113+
memcached:
114+
image: memcached
115+
116+
networks:
117+
- wpdevnet
118+
119+
ports:
120+
- 11211:11211
121+
107122
volumes:
108123
# So that sites aren't wiped every time containers are restarted, MySQL uses a persistent volume.
109124
mysql: {}

tools/local-env/scripts/start.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,10 @@ if ( process.arch === 'arm64' ) {
99
}
1010

1111
// Start the local-env containers.
12-
execSync( 'docker-compose up -d wordpress-develop', { stdio: 'inherit' } );
12+
const containers = ( process.env.LOCAL_PHP_MEMCACHED === 'true' )
13+
? 'wordpress-develop memcached'
14+
: 'wordpress-develop';
15+
execSync( `docker-compose up -d -- ${containers}`, { stdio: 'inherit' } );
1316

1417
// If Docker Toolbox is being used, we need to manually forward LOCAL_PORT to the Docker VM.
1518
if ( process.env.DOCKER_TOOLBOX_INSTALL_PATH ) {

0 commit comments

Comments
 (0)