Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ native/swift/Sources/wordpress-api-wrapper/*.swift
.wordpress
test_credentials
/logs
dump.sql

# CI Cache
.cargo
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -195,10 +195,10 @@ stop-server: delete-wp-plugins-backup
docker-compose down

dump-mysql:
docker exec -it wordpress-rs-mysql-1 /bin/bash -c "mysqldump --defaults-extra-file=mysql_config/config.cnf --no-tablespaces wordpress > dump.sql"
docker exec -it wordpress-rs-database-1 mariadb-dump -u wordpress -pwordpress --no-tablespaces wordpress > dump.sql

restore-mysql:
docker exec -it wordpress-rs-mysql-1 /bin/bash -c "mysql --defaults-extra-file=mysql_config/config.cnf --database wordpress < dump.sql"
cat dump.sql | docker exec -i wordpress-rs-database-1 mariadb -u wordpress -pwordpress --database wordpress

backup-wp-content-plugins:
docker exec -it wordpress /bin/bash -c "cp -R ./wp-content/plugins /tmp/backup_wp_plugins"
Expand Down
17 changes: 3 additions & 14 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,36 +9,25 @@ services:
- .wordpress:/var/www/html
- ./test_credentials:/tmp/test_credentials
environment:
WORDPRESS_DB_HOST: mysql
WORDPRESS_DB_HOST: database
WORDPRESS_DB_USER: wordpress
WORDPRESS_DB_PASSWORD: wordpress
WORDPRESS_DB_NAME: wordpress
WORDPRESS_CONFIG_EXTRA: |
# Allow application passwords to be used without HTTPS
define( 'WP_ENVIRONMENT_TYPE', 'local' );

depends_on:
mysql:
condition: service_healthy
healthcheck:
test: ["CMD", "bash" ,"-c", "[ -f /var/www/html/wp-config.php ]"]
interval: 4s
timeout: 1s
retries: 30

mysql:
image: 'public.ecr.aws/docker/library/mysql:8.0'
database:
image: 'public.ecr.aws/docker/library/mariadb:11.2'
ports:
- '3306:3306'
environment:
MYSQL_DATABASE: 'wordpress'
MYSQL_USER: 'wordpress'
MYSQL_PASSWORD: 'wordpress'
MYSQL_RANDOM_ROOT_PASSWORD: true
volumes:
- ./mysql_config:/mysql_config
healthcheck:
test: ["CMD", "mysqladmin" ,"ping", "-h", "localhost"]
interval: 4s
timeout: 1s
retries: 30
4 changes: 0 additions & 4 deletions mysql_config/config.cnf

This file was deleted.

35 changes: 34 additions & 1 deletion scripts/setup-test-site.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,46 @@ set -e
curl https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar --output /usr/bin/wp
chmod +x /usr/bin/wp

# Install `mysqlcheck` – needed for `wp db check`
apt update && apt install -y default-mysql-client

# Create wpcli working directory (it can't be created by the `www-data` user`)
mkdir -p /var/www/.wp-cli
chown -R www-data:www-data /var/www/.wp-cli/

# Run all the commands below as `www-data` (because that's what WordPress uses itself, so there shouldn't
# be any weird permissions issues)
su -s /bin/bash www-data

## Install WordPress
## Download WordPress
wp core download --force

## Wait for the DB to be ready before attempting install – Docker can do this for us, but we get way better
## diagnostic information from `wp db check`, whereas if `wp core install` fails it won't tell us about issues
## like incompatible SSL cipher suites (which is a problem in the WP 5.7 image when used with MySQL 8+)
tries=0
while true; do

code=0
wp db check || code=$?

if [ $code == 0 ]; then
echo 'Database Ready'
break;
fi

if [ $tries -gt 5 ]; then
echo 'Unable to connect to database'
exit 1
fi

echo 'The database is not ready yet – waiting 5 seconds'
sleep 5

tries=$(( $tries + 1 ))
done

## Install WordPress
wp core install \
--url=localhost \
--title=my-test-site \
Expand Down