From 7e1baccbaeddb8679bfa8f38898decf6ae5be12f Mon Sep 17 00:00:00 2001 From: Casey Bisson Date: Mon, 17 Apr 2017 07:47:04 -0700 Subject: [PATCH 1/2] update to WP 473 --- Dockerfile | 45 +++++++++++++++++++++++---------------- bin/onchange-db.sh | 2 +- bin/onchange-memcached.sh | 2 +- bin/onchange-wp-config.sh | 2 +- docker-compose.yml | 18 ++++++++-------- etc/containerpilot.json | 5 +++++ setup.sh | 2 +- 7 files changed, 45 insertions(+), 31 deletions(-) diff --git a/Dockerfile b/Dockerfile index c012b0d..fa8c7f5 100644 --- a/Dockerfile +++ b/Dockerfile @@ -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 \ + && apt-get update \ && apt-get install -y --no-install-recommends \ curl \ jq \ @@ -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 \ && 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 + && { \ echo 'opcache.memory_consumption=128'; \ echo 'opcache.interned_strings_buffer=8'; \ echo 'opcache.max_accelerated_files=4000'; \ @@ -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 \ @@ -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 \ @@ -58,8 +62,9 @@ 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 \ @@ -67,7 +72,8 @@ RUN export CONSUL_TEMPLATE_VERSION=0.14.0 \ # 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 @@ -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 \ @@ -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 diff --git a/bin/onchange-db.sh b/bin/onchange-db.sh index 63a977d..c5a66de 100755 --- a/bin/onchange-db.sh +++ b/bin/onchange-db.sh @@ -5,5 +5,5 @@ consul-template \ -once \ -dedup \ - -consul ${CONSUL}:8500 \ + -consul-addr ${CONSUL}:8500 \ -template "/var/www/html/db-config.php.ctmpl:/var/www/html/content/db-config.php" diff --git a/bin/onchange-memcached.sh b/bin/onchange-memcached.sh index e49da02..2e9b515 100755 --- a/bin/onchange-memcached.sh +++ b/bin/onchange-memcached.sh @@ -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" diff --git a/bin/onchange-wp-config.sh b/bin/onchange-wp-config.sh index d2841e3..b71642a 100755 --- a/bin/onchange-wp-config.sh +++ b/bin/onchange-wp-config.sh @@ -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" diff --git a/docker-compose.yml b/docker-compose.yml index 1635d90..024204b 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -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: @@ -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 @@ -34,7 +34,7 @@ consul: dns: - 127.0.0.1 labels: - - triton.cns.services=consul + - triton.cns.services=wp-consul # Soft anti-affinity to avoid all other containers - com.docker.swarm.affinities=["container!=~*"] - com.joyent.package=g4-highcpu-128M @@ -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 @@ -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 @@ -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 @@ -96,7 +96,7 @@ nginx: environment: - CONSUL_AGENT=1 labels: - - triton.cns.services=nginx + - triton.cns.services=wp-nginx, nginx - com.docker.swarm.affinities=["container!=~*nginx*"] - com.joyent.package=g4-highcpu-512M @@ -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 diff --git a/etc/containerpilot.json b/etc/containerpilot.json index e599741..fa5c341 100644 --- a/etc/containerpilot.json +++ b/etc/containerpilot.json @@ -16,6 +16,11 @@ "poll": 7, "onChange": "/usr/local/bin/onchange-db.sh" }, + { + "name": "mysql-primary", + "poll": 7, + "onChange": "/usr/local/bin/onchange-db.sh" + }, { "name": "nfs", "poll": 11, diff --git a/setup.sh b/setup.sh index fc9e221..e3bb319 100755 --- a/setup.sh +++ b/setup.sh @@ -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 echo >> _env echo 'Edit the _env file to confirm and set your desired configuration details' From 9455b4edc5cd8b1bfd80740ccac7324baa6e6ac0 Mon Sep 17 00:00:00 2001 From: Casey Bisson Date: Mon, 17 Apr 2017 09:35:59 -0700 Subject: [PATCH 2/2] no spaces, duh --- docker-compose.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker-compose.yml b/docker-compose.yml index 024204b..657e3b4 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -96,7 +96,7 @@ nginx: environment: - CONSUL_AGENT=1 labels: - - triton.cns.services=wp-nginx, nginx + - triton.cns.services=wp-nginx,nginx - com.docker.swarm.affinities=["container!=~*nginx*"] - com.joyent.package=g4-highcpu-512M