Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update to WordPress 4.7.3 #45

Merged
merged 2 commits into from
Apr 18, 2017
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
45 changes: 27 additions & 18 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ FROM php:5.6-apache
RUN a2enmod rewrite

# Install the PHP extensions we need, and other packages
RUN apt-get update \
RUN set -ex \
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Prefixing all the run statements with set -ex for easier debugging, as is used in some other repos

&& apt-get update \
&& apt-get install -y --no-install-recommends \
curl \
jq \
Expand All @@ -14,14 +15,15 @@ RUN apt-get update \
nfs-common \
unzip \
&& rm -rf /var/lib/apt/lists/* \
&& pecl install memcached \
# Memcached 2.2.0 is the latest for PHP < 7
# see https://pecl.php.net/package/memcached
&& pecl install memcached-2.2.0 \
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Choosing not to bump the base image up to PHP 7, so I have to be more specific here

&& docker-php-ext-configure gd --with-png-dir=/usr --with-jpeg-dir=/usr \
&& docker-php-ext-install gd mysqli opcache \
&& docker-php-ext-enable memcached

# Set recommended PHP.ini settings
# See https://secure.php.net/manual/en/opcache.installation.php
RUN { \
&& docker-php-ext-enable memcached \
# Set recommended PHP.ini settings
# See https://secure.php.net/manual/en/opcache.installation.php
&& { \
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Just joining this with the previous run statement for one less layer

echo 'opcache.memory_consumption=128'; \
echo 'opcache.interned_strings_buffer=8'; \
echo 'opcache.max_accelerated_files=4000'; \
Expand All @@ -36,10 +38,11 @@ COPY etc /etc

# Add Containerpilot and its configuration
# Releases at https://github.com/joyent/containerpilot/releases
ENV CONTAINERPILOT_VER 2.3.0
ENV CONTAINERPILOT_VER 2.7.2
ENV CONTAINERPILOT file:///etc/containerpilot.json

RUN export CONTAINERPILOT_CHECKSUM=ec9dbedaca9f4a7a50762f50768cbc42879c7208 \
RUN set -ex \
&& export CONTAINERPILOT_CHECKSUM=e886899467ced6d7c76027d58c7f7554c2fb2bcc \
&& curl --retry 7 --fail -Lso /tmp/containerpilot.tar.gz \
"https://github.com/joyent/containerpilot/releases/download/${CONTAINERPILOT_VER}/containerpilot-${CONTAINERPILOT_VER}.tar.gz" \
&& echo "${CONTAINERPILOT_CHECKSUM} /tmp/containerpilot.tar.gz" | sha1sum -c \
Expand All @@ -48,8 +51,9 @@ RUN export CONTAINERPILOT_CHECKSUM=ec9dbedaca9f4a7a50762f50768cbc42879c7208 \

# Install Consul
# Releases at https://releases.hashicorp.com/consul
RUN export CONSUL_VERSION=0.6.4 \
&& export CONSUL_CHECKSUM=abdf0e1856292468e2c9971420d73b805e93888e006c76324ae39416edcf0627 \
RUN set -ex \
&& export CONSUL_VERSION=0.7.5 \
&& export CONSUL_CHECKSUM=40ce7175535551882ecdff21fdd276cef6eaab96be8a8260e0599fadb6f1f5b8 \
&& curl --retry 7 --fail -vo /tmp/consul.zip "https://releases.hashicorp.com/consul/${CONSUL_VERSION}/consul_${CONSUL_VERSION}_linux_amd64.zip" \
&& echo "${CONSUL_CHECKSUM} /tmp/consul.zip" | sha256sum -c \
&& unzip /tmp/consul -d /usr/local/bin \
Expand All @@ -58,16 +62,18 @@ RUN export CONSUL_VERSION=0.6.4 \

# Install Consul template
# Releases at https://releases.hashicorp.com/consul-template/
RUN export CONSUL_TEMPLATE_VERSION=0.14.0 \
&& export CONSUL_TEMPLATE_CHECKSUM=7c70ea5f230a70c809333e75fdcff2f6f1e838f29cfb872e1420a63cdf7f3a78 \
RUN set -ex \
&& export CONSUL_TEMPLATE_VERSION=0.18.2 \
&& export CONSUL_TEMPLATE_CHECKSUM=6fee6ab68108298b5c10e01357ea2a8e4821302df1ff9dd70dd9896b5c37217c \
&& curl --retry 7 --fail -Lso /tmp/consul-template.zip "https://releases.hashicorp.com/consul-template/${CONSUL_TEMPLATE_VERSION}/consul-template_${CONSUL_TEMPLATE_VERSION}_linux_amd64.zip" \
&& echo "${CONSUL_TEMPLATE_CHECKSUM} /tmp/consul-template.zip" | sha256sum -c \
&& unzip /tmp/consul-template.zip -d /usr/local/bin \
&& rm /tmp/consul-template.zip

# Install wp-cli, http://wp-cli.org
ENV WP_CLI_CONFIG_PATH /var/www/html/wp-cli.yml
RUN curl --retry 7 --fail -Ls -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar \
RUN set -ex \
&& curl --retry 7 --fail -Ls -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar \
&& chmod +x wp-cli.phar \
&& mv wp-cli.phar /usr/local/bin/wp \
&& wp --info --allow-root
Expand All @@ -78,13 +84,15 @@ COPY /var/www/html /var/www/html
RUN chown -R www-data:www-data /var/www/html/*

# Install WordPress via wp-cli & move the default themes to our content dir
ENV WORDPRESS_VERSION 4.5.3
RUN wp --allow-root core download --version=${WORDPRESS_VERSION} \
ENV WORDPRESS_VERSION 4.7.3
RUN set -ex \
&& wp --allow-root core download --version=${WORDPRESS_VERSION} \
&& mv /var/www/html/wordpress/wp-content/themes/* /var/www/html/content/themes/

# Install HyperDB, https://wordpress.org/plugins/hyperdb
# Releases at https://wordpress.org/plugins/hyperdb/developers/ , though no SHA1 fingerprints are published
RUN export HYPERDB_VERSION=1.1 \
RUN set -ex \
&& export HYPERDB_VERSION=1.1 \
&& curl --retry 7 --fail -Ls -o /var/www/html/hyperdb.zip https://downloads.wordpress.org/plugin/hyperdb.${HYPERDB_VERSION}.zip \
&& unzip hyperdb.zip \
&& chown -R www-data:www-data /var/www/html/hyperdb \
Expand All @@ -93,7 +101,8 @@ RUN export HYPERDB_VERSION=1.1 \
&& touch /var/www/html/content/db-config.php

# Install ztollman's object-cache.php or object caching to memcached
RUN curl --retry 7 --fail -Ls -o /var/www/html/content/object-cache.php https://raw.githubusercontent.com/tollmanz/wordpress-pecl-memcached-object-cache/master/object-cache.php
RUN set -ex \
&& curl --retry 7 --fail -Ls -o /var/www/html/content/object-cache.php https://raw.githubusercontent.com/tollmanz/wordpress-pecl-memcached-object-cache/master/object-cache.php

# The volume is defined after we install everything
VOLUME /var/www/html
Expand Down
2 changes: 1 addition & 1 deletion bin/onchange-db.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@
consul-template \
-once \
-dedup \
-consul ${CONSUL}:8500 \
-consul-addr ${CONSUL}:8500 \
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The latest version of consul-template was throwing warnings/notices about the change to the argument

-template "/var/www/html/db-config.php.ctmpl:/var/www/html/content/db-config.php"
2 changes: 1 addition & 1 deletion bin/onchange-memcached.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
consul-template \
-once \
-dedup \
-consul ${CONSUL}:8500 \
-consul-addr ${CONSUL}:8500 \
-template "/var/www/html/memcached-config.php.ctmpl:/var/www/html/memcached-config.php"
2 changes: 1 addition & 1 deletion bin/onchange-wp-config.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
consul-template \
-once \
-dedup \
-consul ${CONSUL}:8500 \
-consul-addr ${CONSUL}:8500 \
-template "/var/www/html/wp-config.php.ctmpl:/var/www/html/wp-config.php"
18 changes: 9 additions & 9 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# An demo version of WordPress for easy scaling
wordpress:
image: autopilotpattern/wordpress:latest
image: autopilotpattern/wordpress:4.7.3-r4.0.0
restart: always
env_file: _env
environment:
Expand All @@ -10,7 +10,7 @@ wordpress:
- 9090
labels:
# Setting the CNS service name
- triton.cns.services=wordpress
- triton.cns.services=wp-wordpress
# Soft anti-affinity to avoid other WordPress instances
- com.docker.swarm.affinities=["container!=~*wordpress*"]
# Set the package
Expand All @@ -34,7 +34,7 @@ consul:
dns:
- 127.0.0.1
labels:
- triton.cns.services=consul
- triton.cns.services=wp-consul
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is a breaking change for upgrades from previous versions of this project, but we've discovered that namespacing Consul is critical for supporting multiple projects in a single DC

# Soft anti-affinity to avoid all other containers
- com.docker.swarm.affinities=["container!=~*"]
- com.joyent.package=g4-highcpu-128M
Expand All @@ -51,7 +51,7 @@ nfs:
- 1892
- 2049
labels:
- triton.cns.services=nfs
- triton.cns.services=wp-nfs
- com.docker.swarm.affinities=["container!=~*"]
- com.joyent.package=g4-highcpu-256M

Expand All @@ -66,7 +66,7 @@ mysql:
expose:
- 3306
labels:
- triton.cns.services=mysql
- triton.cns.services=wp-mysql
- com.docker.swarm.affinities=["container!=~*mysql*"]
- com.joyent.package=g4-highcpu-4G

Expand All @@ -80,13 +80,13 @@ memcached:
ports:
- 11211
labels:
- triton.cns.services=memcached
- triton.cns.services=wp-memcached
- com.docker.swarm.affinities=["container!=~*memcached*"]
- com.joyent.package=g4-highcpu-512M

# Nginx as a load-balancing tier and reverse proxy
nginx:
image: autopilotpattern/wordpress-nginx:latest
image: autopilotpattern/wordpress-nginx:4.7.3-r4.0.0
restart: always
ports:
- 80
Expand All @@ -96,7 +96,7 @@ nginx:
environment:
- CONSUL_AGENT=1
labels:
- triton.cns.services=nginx
- triton.cns.services=wp-nginx,nginx
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Though I chose to make a breaking change elsewhere, I'm preserving the un-namespaced nginx here because I can't change my Bitly link

- com.docker.swarm.affinities=["container!=~*nginx*"]
- com.joyent.package=g4-highcpu-512M

Expand All @@ -109,6 +109,6 @@ prometheus:
ports:
- 9090
labels:
- triton.cns.services=prometheus
- triton.cns.services=wp-prometheus
- com.docker.swarm.affinities=["container!=~*prometheus*"]
- com.joyent.package=g4-highcpu-1G
5 changes: 5 additions & 0 deletions etc/containerpilot.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@
"poll": 7,
"onChange": "/usr/local/bin/onchange-db.sh"
},
{
"name": "mysql-primary",
Copy link
Contributor Author

Choose a reason for hiding this comment

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

We should have been tracking this all along.

Currently there's a race condition while doing rolling updates of MySQL. If the new mysql-primary becomes healthy after all changes to the mysql services change, then WordPress won't recognize it. This is intended to fix that.

"poll": 7,
"onChange": "/usr/local/bin/onchange-db.sh"
},
{
"name": "nfs",
"poll": 11,
Expand Down
2 changes: 1 addition & 1 deletion setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ envcheck() {
echo >> _env

echo '# Consul discovery via Triton CNS' >> _env
echo CONSUL=consul.svc.${TRITON_ACCOUNT}.${TRITON_DC}.cns.joyent.com >> _env
echo CONSUL=wp-consul.svc.${TRITON_ACCOUNT}.${TRITON_DC}.cns.joyent.com >> _env
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Applying the new namespacing here

echo >> _env

echo 'Edit the _env file to confirm and set your desired configuration details'
Expand Down