Skip to content

Commit

Permalink
feat: Add SSL development option (fix #8211)
Browse files Browse the repository at this point in the history
  • Loading branch information
tofumatt committed Aug 7, 2018
1 parent d74a4fc commit fbc9423
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 7 deletions.
9 changes: 7 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,14 @@ cd gutenberg
```

Then, run a setup script to check if docker and node are configured properly and starts the local WordPress instance. You may need to run this script multiple times if prompted.
```
```bash
./bin/setup-local-env.sh
```
```

If you want to access the site via HTTPS, you can set up your local environment to use SSL:
```bash
./bin/setup-local-env.sh --ssl
```

If everything was successful, you'll see the following ascii art:
```
Expand Down
18 changes: 13 additions & 5 deletions bin/install-wordpress.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,21 @@ if [ "$1" == '--e2e_tests' ]; then
fi
fi

# By default we use HTTP to serve the site, but we allow SSL sites with a
# flag.
PROTOCOL='http'
if [ "$1" == '--ssl' ]; then
HOST_PORT=$(docker-compose port wordpress 443 | awk -F : '{printf $2}')
PROTOCOL='https'
fi

# Get the host port for the WordPress container.
HOST_PORT=$(docker-compose port $CONTAINER 80 | awk -F : '{printf $2}')

# Wait until the Docker containers are running and the WordPress site is
# responding to requests.
echo -en $(status_message "Attempting to connect to WordPress...")
until $(curl -L http://localhost:$HOST_PORT -so - 2>&1 | grep -q "WordPress"); do
until $(curl -L --insecure $PROTOCOL://localhost:$HOST_PORT -so - 2>&1 | grep -q "WordPress"); do
echo -n '.'
sleep 5
done
Expand All @@ -50,7 +58,7 @@ fi
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 run --rm -u 33 $CLI core install --title="$SITE_TITLE" --admin_user=admin --admin_password=password [email protected] --skip-email --url=$PROTOCOL://localhost:$HOST_PORT >/dev/null

if [ "$WP_VERSION" == "latest" ]; then
# Check for WordPress updates, to make sure we're running the very latest version.
Expand All @@ -59,9 +67,9 @@ 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)
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
if [ "$CURRENT_URL" != "$PROTOCOL://localhost:$HOST_PORT" ]; then
docker-compose run --rm $CLI option update home "$PROTOCOL://localhost:$HOST_PORT" >/dev/null
docker-compose run --rm $CLI option update siteurl "$PROTOCOL://localhost:$HOST_PORT" >/dev/null
fi

# Activate Gutenberg.
Expand Down
8 changes: 8 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ services:
image: wordpress
ports:
- 8888:80
- 9999:443
environment:
WORDPRESS_DB_PASSWORD: example
ABSPATH: /usr/src/wordpress/
Expand All @@ -14,6 +15,13 @@ services:
- .:/var/www/html/wp-content/plugins/gutenberg
- ./test/e2e/test-plugins:/var/www/html/wp-content/plugins/gutenberg-test-plugins
- ./test/e2e/test-mu-plugins:/var/www/html/wp-content/mu-plugins
command: |
/bin/bash -c "
apt-get update && \
apt-get install -y --no-install-recommends ssl-cert && \
a2enmod ssl && \
a2ensite default-ssl && \
docker-entrypoint.sh apache2-foreground"
cli:
image: wordpress:cli
Expand Down

0 comments on commit fbc9423

Please sign in to comment.