Skip to content

Commit

Permalink
Merge pull request #2 from 10up/nfs
Browse files Browse the repository at this point in the history
nfs WIP 04/04/2106
  • Loading branch information
misterbisson committed Apr 5, 2016
2 parents 1eeae3a + 16e2c55 commit 01bbf79
Show file tree
Hide file tree
Showing 7 changed files with 57 additions and 2 deletions.
5 changes: 5 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@ RUN apt-get update && apt-get install -y libmemcached-dev \
&& pecl install memcached \
&& docker-php-ext-enable memcached

# install nfs support for WordPress uploads directory
# using --no-install-recommends to prevent python install
RUN apt-get install -y --no-install-recommends \
nfs-common

# set recommended PHP.ini settings
# see https://secure.php.net/manual/en/opcache.installation.php
RUN { \
Expand Down
15 changes: 15 additions & 0 deletions common-compose.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,24 @@
wordpress:
build: .
privileged: true
env_file: _env
environment:
- CONTAINERBUDDY=file:///opt/containerbuddy/config.json

nfs:
image: autopilot-nfs
privileged: true
mem_limit: 256m
restart: always
labels:
- triton.cns.services=nfs
expose:
- 111
- 1892
- 2049
environment:
- CONSUL=consul

# MySQL designed for container-native deployment on Joyent's Triton platform.

mysql:
Expand Down
5 changes: 5 additions & 0 deletions containerbuddy/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@
"poll": 5,
"onChange": "/opt/containerbuddy/onchange_reload-db.sh"
},
{
"name": "nfs",
"poll": 5,
"onChange": "/opt/containerbuddy/onchange_reload-nfs.sh"
},
{
"name": "memcached",
"poll": 5,
Expand Down
10 changes: 10 additions & 0 deletions containerbuddy/onchange_reload-nfs.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/bash

if [[ `curl -s ${CONSUL}:8500/v1/health/state/passing | grep nfs` ]]
then
echo "nfs is healthy, mounting uploads directory...."
mount -t nfs -v -o nolock,vers=3 nfs:/exports /var/www/html/content/uploads
else
echo "nfs is not healthly, umounting uploads directory..."
umount -f -l /var/www/html/content/uploads
fi
8 changes: 7 additions & 1 deletion containerbuddy/onstart.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,13 @@ do
sleep 5
done

echo "mysql-primary is now health, moving on..."
until [[ `curl -s ${CONSUL}:8500/v1/health/state/passing | grep nfs` ]]
do
echo "no healthly nfs server avaliable yet...."
sleep 5
done

echo "mysql-primary and nfs are now healthly, moving on..."

/opt/containerbuddy/onchange_reload-db.sh
/opt/containerbuddy/onchange_reload-memcached.sh
Expand Down
2 changes: 1 addition & 1 deletion containerbuddy/wp-config.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ consul-template \
-once \
-dedup \
-consul ${CONSUL}:8500 \
-template "/var/www/html/wp-config.php.ctmpl:/var/www/html/wp-config.php"
-template "/var/www/html/consul-templates/wp-config.php.ctmpl:/var/www/html/wp-config.php"
14 changes: 14 additions & 0 deletions local-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,25 @@ wordpress:
service: wordpress
links:
- consul:consul
- nfs:nfs
mem_limit: 512m
restart: never
ports:
- "80"

nfs:
extends:
file: common-compose.yml
service: nfs
environment:
- CONSUL=consul
- CONTAINERBUDDY=file:///etc/containerbuddy.json
links:
- consul:consul
ports:
- "111"
- "1892:1892"
- "2049"

mysql:
extends:
Expand Down

0 comments on commit 01bbf79

Please sign in to comment.