Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Docker Appstack WP Instance, via command line
# Version 1.2 - 2015-01-07
# Software -
# 1. Docker:
# SSL Certificates -
# 1. Named localhost.key, localhost.crt
# 2. Located in /tmp/certs
# Docker images -
# 1. appstack-data image:
# 2. appstack-setup-mysql image:
# 3. appstack-mysql image:
# 4. appstack-phpfpm image:
# 5. appstack-apache image:
# 6. appstack-wpcli image:
f_err () {
echo 'Uh, something went wrong:'
echo "$1"
exit 1
pwgen -cns 32 1 > /dev/null || f_err 'Command: pwgen... NOT FOUND'
PWD="$(pwgen -cns 32 1)"
APPNAME="${SITENAME}_$(date +%s)"
if [ -z $SITENAME ] ; then
f_err 'You must supply a site name.'
if [ -z $SMTPSERVER ] ; then
echo "No SMTP SERVER specified. Continuing without mail support."
if [ ! -d /tmp/certs ] ; then
f_err 'You must generate a key and certificate and place it into /tmp/certs for this script to work.'
elif [ ! -f /tmp/certs/localhost.crt ] ; then
f_err 'You must generate a key and certificate and place it into /tmp/certs for this script to work.'
docker run --name ${APPNAME}-data -v ${APPDIR}/html:/var/www/html -v ${APPDIR}/mysql:/var/lib/mysql -v ${APPDIR}/log:/var/log -v ${APPDIR}/backup:/var/backup -v ${APPDIR}/conf:/conf -v ${APPDIR}/secret:/root/.secret -it appstack-data "WordPress: ${SITENAME}"|| f_err 'Failed creating data container'
### COPY 'localhost.{crt|key}' to /conf ###
cp /tmp/certs/localhost.crt ${APPDIR}/conf || f_err 'Failed to copy localhost.crt'
cp /tmp/certs/localhost.key ${APPDIR}/conf || f_err 'Failed to copy localhost.key'
if [[ -f /tmp/certs/ca-cert.crt ]] ; then
cp /tmp/certs/ca-cert.crt ${APPDIR}/conf || f_err 'Failed to copy CA Intermediate Cert'
docker run --volumes-from ${APPNAME}-data -it appstack-setup-mysql || f_err 'MySQL Setup Failed'
docker run --name ${APPNAME}-db --volumes-from ${APPNAME}-data -d appstack-mysql || f_err 'MySQL container Failed'
docker run --name ${APPNAME}-fpm --link ${APPNAME}-db:db --volumes-from ${APPNAME}-data -e SMTPSERVER="${SMTPSERVER}" -d appstack-php-fpm || f_err 'PHP-FPM container failed'
docker run --volumes-from ${APPNAME}-data -w /var/www/html -it appstack-wpcli /scripts/ || f_err 'Failed WP download'
docker run --volumes-from ${APPNAME}-data -w /var/www/html -it appstack-wpcli /scripts/ || f_err 'Failed wp-config.php generation'
docker run --link ${APPNAME}-db:db --volumes-from ${APPNAME}-data -w /var/www/html -e SITENAME="https://${SITENAME}" -e TITLE="${SITENAME}" -e ADMIN="admin" -e ADMINPASS="${PWD}" -e ADMINEMAIL='' -it appstack-wpcli /scripts/ || f_err 'Failed WP install'
docker run --name ${APPNAME}-apache --link ${APPNAME}-fpm:fpm --volumes-from ${APPNAME}-data -p 80:80 -p 443:443 -e 'SITENAME=${SITENAME}' -d appstack-apache || f_err 'Apache container failed'
echo "Username: admin"
echo "Password: ${PWD}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.