-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow access to the WordPress installation if DOCKER_ENV=localwpdev (#…
- Loading branch information
1 parent
a88f379
commit 29ccdcb
Showing
8 changed files
with
56 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,3 +14,4 @@ languages/gutenberg.pot | |
phpcs.xml | ||
yarn.lock | ||
docker-compose.override.yml | ||
/wordpress |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#!/usr/bin/env bash | ||
|
||
WP_VERSION=${WP_VERSION-latest} | ||
DOCKER=${DOCKER-false} | ||
DOCKER_ENV=${DOCKER_ENV-ci} | ||
DOCKER_COMPOSE_FILE_OPTIONS="-f docker-compose.yml" | ||
|
||
if [ "$DOCKER_ENV" == "localwpdev" ]; then | ||
DOCKER_COMPOSE_FILE_OPTIONS="${DOCKER_COMPOSE_FILE_OPTIONS} -f docker-compose-localdev.yml" | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,11 +6,13 @@ set -e | |
# Gutenberg script includes. | ||
. "$(dirname "$0")/includes.sh" | ||
|
||
# Set up environment variables | ||
. "$(dirname "$0")/bootstrap-env.sh" | ||
|
||
# These are the containers and values for the development site. | ||
CLI='cli' | ||
CONTAINER='wordpress' | ||
SITE_TITLE='Gutenberg Dev' | ||
WP_VERSION=${WP_VERSION-latest} | ||
|
||
# If we're installing/re-installing the test site, change the containers used. | ||
if [ "$1" == '--e2e_tests' ]; then | ||
|
@@ -20,15 +22,15 @@ if [ "$1" == '--e2e_tests' ]; then | |
|
||
if ! docker ps | grep -q $CONTAINER; then | ||
echo -e $(error_message "WordPress e2e tests run in their own Docker container, but that container wasn't found.") | ||
echo "Please restart your Docker containers by running 'docker-compose down && docker-compose up -d' or" | ||
echo "Please restart your Docker containers by running 'docker-compose $DOCKER_COMPOSE_FILE_OPTIONS down && docker-compose $DOCKER_COMPOSE_FILE_OPTIONS up -d' or" | ||
echo "by running './bin/setup-local-env.sh' again." | ||
echo "" | ||
exit 1 | ||
fi | ||
fi | ||
|
||
# Get the host port for the WordPress container. | ||
HOST_PORT=$(docker-compose port $CONTAINER 80 | awk -F : '{printf $2}') | ||
HOST_PORT=$(docker-compose $DOCKER_COMPOSE_FILE_OPTIONS port $CONTAINER 80 | awk -F : '{printf $2}') | ||
|
||
# Wait until the Docker containers are running and the WordPress site is | ||
# responding to requests. | ||
|
@@ -43,27 +45,27 @@ echo '' | |
# dirty up the tests. | ||
if [ "$1" == '--e2e_tests' ]; then | ||
echo -e $(status_message "Resetting test database...") | ||
docker-compose run --rm $CLI db reset --yes >/dev/null | ||
docker-compose $DOCKER_COMPOSE_FILE_OPTIONS run --rm $CLI db reset --yes >/dev/null | ||
fi | ||
|
||
# Install WordPress. | ||
echo -e $(status_message "Installing WordPress...") | ||
# The `-u 33` flag tells Docker to run the command as a particular user and | ||
# prevents permissions errors. See: https://github.com/WordPress/gutenberg/pull/8427#issuecomment-410232369 | ||
docker-compose run --rm -u 33 $CLI core install --title="$SITE_TITLE" --admin_user=admin --admin_password=password [email protected] --skip-email --url=http://localhost:$HOST_PORT >/dev/null | ||
docker-compose $DOCKER_COMPOSE_FILE_OPTIONS run --rm -u 33 $CLI core install --title="$SITE_TITLE" --admin_user=admin --admin_password=password [email protected] --skip-email --url=http://localhost:$HOST_PORT >/dev/null | ||
|
||
if [ "$WP_VERSION" == "latest" ]; then | ||
# Check for WordPress updates, to make sure we're running the very latest version. | ||
docker-compose run --rm -u 33 $CLI core update >/dev/null | ||
docker-compose $DOCKER_COMPOSE_FILE_OPTIONS run --rm -u 33 $CLI core update >/dev/null | ||
fi | ||
|
||
# If the 'wordpress' volume wasn't during the down/up earlier, but the post port has changed, we need to update it. | ||
CURRENT_URL=$(docker-compose run -T --rm $CLI option get siteurl) | ||
CURRENT_URL=$(docker-compose $DOCKER_COMPOSE_FILE_OPTIONS run -T --rm $CLI option get siteurl) | ||
if [ "$CURRENT_URL" != "http://localhost:$HOST_PORT" ]; then | ||
docker-compose run --rm $CLI option update home "http://localhost:$HOST_PORT" >/dev/null | ||
docker-compose run --rm $CLI option update siteurl "http://localhost:$HOST_PORT" >/dev/null | ||
docker-compose $DOCKER_COMPOSE_FILE_OPTIONS run --rm $CLI option update home "http://localhost:$HOST_PORT" >/dev/null | ||
docker-compose $DOCKER_COMPOSE_FILE_OPTIONS run --rm $CLI option update siteurl "http://localhost:$HOST_PORT" >/dev/null | ||
fi | ||
|
||
# Activate Gutenberg. | ||
echo -e $(status_message "Activating Gutenberg...") | ||
docker-compose run --rm $CLI plugin activate gutenberg >/dev/null | ||
docker-compose $DOCKER_COMPOSE_FILE_OPTIONS run --rm $CLI plugin activate gutenberg >/dev/null |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
version: '3.1' | ||
|
||
services: | ||
|
||
wordpress: | ||
volumes: | ||
- ./wordpress:/var/www/html | ||
|
||
cli: | ||
image: wordpress:cli | ||
volumes: | ||
- ./wordpress:/var/www/html |
29ccdcb
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
x