-
-
Save saladinjake/395d4e90e4f201646e34dfca75587992 to your computer and use it in GitHub Desktop.
Docker Appstack WP Instance, via command line
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Version 1.2 - 2015-01-07 | |
# https://gist.github.com/clcollins/cfab1f63dc1aa927bf9f | |
# REQUIRES: | |
# | |
# Software - | |
# 1. Docker: https://docker.com | |
# | |
# SSL Certificates - | |
# 1. Named localhost.key, localhost.crt | |
# 2. Located in /tmp/certs | |
# | |
# Docker images - | |
# 1. appstack-data image: https://github.com/DockerDemos/appstack-data | |
# 2. appstack-setup-mysql image: https://github.com/DockerDemos/appstack-setup-mysql | |
# 3. appstack-mysql image: https://github.com/DockerDemos/appstack-mysql | |
# 4. appstack-phpfpm image: https://github.com/DockerDemos/appstack-phpfpm | |
# 5. appstack-apache image: https://github.com/DockerDemos/appstack-apache | |
# 6. appstack-wpcli image: https://github.com/DockerDemos/appstack-wpcli | |
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)" | |
SITENAME="$1" | |
SMTPSERVER="$2" | |
APPNAME="${SITENAME}_$(date +%s)" | |
APPDIR="/tmp/${APPNAME}" | |
if [ -z $SITENAME ] ; then | |
f_err 'You must supply a site name.' | |
fi | |
if [ -z $SMTPSERVER ] ; then | |
echo "No SMTP SERVER specified. Continuing without mail support." | |
fi | |
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.' | |
fi | |
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' | |
fi | |
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/core-download.sh || f_err 'Failed WP download' | |
docker run --volumes-from ${APPNAME}-data -w /var/www/html -it appstack-wpcli /scripts/core-config.sh || 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='[email protected]' -it appstack-wpcli /scripts/core-install.sh || 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