Skip to content

Conversation

@johnbillion
Copy link
Member

@johnbillion johnbillion commented May 8, 2022

Trac ticket: https://core.trac.wordpress.org/ticket/55700

This moves the Memcached container into the Docker Compose config so it can be used with the local dev environment just by flipping the LOCAL_PHP_MEMCACHED environment variable value.

Testing

Ensure Docker Desktop is running if necessary.

Test with the object cache enabled:

  • In your .env file enable the memcached config via LOCAL_PHP_MEMCACHED=true
  • Run npm run env:restart
  • Confirm the object-cache.php drop-in is present on http://localhost:8889/wp-admin/plugins.php?plugin_status=dropins
  • Use WP-CLI or a debugging plugin such as Query Monitor to confirm that the Memcached object cache is in use

Test with the object cache disabled:

  • In your .env file disable the memcached config via LOCAL_PHP_MEMCACHED=false
  • Run npm run env:restart
  • Confirm the object-cache.php drop-in is no longer present on http://localhost:8889/wp-admin/plugins.php?plugin_status=dropins
  • Use WP-CLI or a debugging plugin such as Query Monitor to confirm that the Memcached object cache is no longer in use
@johnbillion johnbillion marked this pull request as draft May 8, 2022 19:23
@johnbillion johnbillion changed the title Move the Memcached container into the Docker Compose config #55700: Move the Memcached container into the Docker Compose config May 8, 2022
@johnbillion johnbillion marked this pull request as ready for review August 11, 2022 16:25
Copy link
Member

@desrosj desrosj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested and looks great for me on MacOS.

@johnbillion johnbillion deleted the local-memcached branch August 13, 2022 23:24
const containers = ( process.env.LOCAL_PHP_MEMCACHED === 'true' )
? 'wordpress-develop memcached'
: 'wordpress-develop';
execSync( `docker-compose up -d -- ${containers}`, { stdio: 'inherit' } );
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@johnbillion Is there a specific reason for the inclusion of -- here? I found that it causes an error in docker-compose, at least in v1.25.0 on Linux:

npm run env:start > WordPress@6.1.0 env:start /home/westonruter/repos/wordpress-develop > node ./tools/local-env/scripts/start.js Creating network "wordpress-develop_wpdevnet" with driver "bridge" ERROR: No such service: -- child_process.js:866 throw err; ^ Error: Command failed: docker-compose up -d -- wordpress-develop at checkExecSyncError (child_process.js:790:11) at execSync (child_process.js:863:15) at Object.<anonymous> (/home/westonruter/repos/wordpress-develop/tools/local-env/scripts/start.js:11:1) at Module._compile (internal/modules/cjs/loader.js:1085:14) at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10) at Module.load (internal/modules/cjs/loader.js:950:32) at Function.Module._load (internal/modules/cjs/loader.js:790:12) at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:75:12) at internal/main/run_main_module.js:17:47 { status: 1, signal: null, output: [ null, null, null ], pid: 8626, stdout: null, stderr: null } npm ERR! code ELIFECYCLE npm ERR! errno 1 npm ERR! WordPress@6.1.0 env:start: `node ./tools/local-env/scripts/start.js` npm ERR! Exit status 1 

If I remove the -- then the command runs successfully.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assume there was a reason but I don't remember it. Can you open a ticket? 👍

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

3 participants