From 7d30562e98768e75cfc8c7a964e1912e87ab26c5 Mon Sep 17 00:00:00 2001 From: diosmosis Date: Sun, 1 Oct 2023 18:52:13 -0700 Subject: [PATCH] Add wp service to docker-compose for an easy way to run the wp-cli in the local docker environment. --- README.md | 8 ++++++++ docker-compose.yml | 37 ++++++++++++++++++++++++++----------- 2 files changed, 34 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index f5430e9d2..c44f3a803 100644 --- a/README.md +++ b/README.md @@ -72,6 +72,14 @@ variables are supported: This is the same format as the Active Plugins entry in the System Report, so you could copy that value to this environment variable to quickly (or more quickly) replicate a user's setup. +**Running wp-cli** + +Make sure the wordpress service is running in one terminal, then in another terminal run: + +```bash +docker-compose run wp <... rest of command ...> +``` + **Accessing MariaDB/MySQL** First ensure the database you want to inspect (mariadb or mysql) is the one that's currently being used by your local diff --git a/docker-compose.yml b/docker-compose.yml index eee509649..19f57dc2c 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -18,8 +18,6 @@ services: ports: - "${PORT:-3000}:80" environment: - WP_DB_USER: root - WP_DB_PASSWORD: pass WP_DB_HOST: "${BACKEND:-mariadb}" entrypoint: - bash @@ -58,8 +56,8 @@ services: echo "done." # create database if it does not already exist - export WP_DB_NAME=$$(echo "wp_matomo_$$WORDPRESS_VERSION" | sed 's/\./_/g') - php -r "\$$pdo = new PDO('mysql:host=$$WP_DB_HOST', '$$WP_DB_USER', '$$WP_DB_PASSWORD'); + WP_DB_NAME=$$(echo "wp_matomo_$$WORDPRESS_VERSION" | sed 's/\./_/g') + php -r "\$$pdo = new PDO('mysql:host=$$WP_DB_HOST', 'root', 'pass'); \$$pdo->exec('CREATE DATABASE IF NOT EXISTS \`$$WP_DB_NAME\`');\ \$$pdo->exec('GRANT ALL PRIVILEGES ON $$WP_DB_NAME.* TO \'root\'@\'%\' IDENTIFIED BY \'pass\'');" @@ -67,14 +65,14 @@ services: if [ ! -f "/var/www/html/$$WORDPRESS_VERSION/wp-config.php" ]; then cat > "/var/www/html/$$WORDPRESS_VERSION/wp-config.php" <