Last active
May 25, 2016 18:14
-
-
Save shankie-codes/3785ce4bc515b058d97070b43a5d3203 to your computer and use it in GitHub Desktop.
docker-machine-create-wordpress-nginx-digitalocean-droplet
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 | |
echo "Enter the hostname that you'd like to create:" | |
read HOSTNAME | |
if [ -z "$DO_TOKEN" ]; then | |
echo "Enter your Digital Ocean access token:" | |
read DO_TOKEN | |
fi | |
if [ -z "$PUBLIC_KEYS" ]; then | |
echo "Enter your public keys followed by Ctrl-D:" | |
PUBLIC_KEYS=$(cat) | |
fi | |
docker-machine create \ | |
--driver digitalocean \ | |
--digitalocean-backups=true \ | |
--digitalocean-region=lon1 \ | |
--digitalocean-access-token=$DO_TOKEN \ | |
$HOSTNAME | |
eval "$(docker-machine env $HOSTNAME)" | |
docker run -p 80:80 -p 3306:3306 --restart=always --name docker-wordpress-nginx -d -v /wordpress/uploads:/usr/share/nginx/www/wp-content/uploads -v /wordpress/plugins:/usr/share/nginx/www/wp-content/plugins -v /wordpress/themes:/usr/share/nginx/www/wp-content/themes eugeneware/docker-wordpress-nginx | |
docker-machine ssh $HOSTNAME fallocate -l 2G /swapfile | |
docker-machine ssh $HOSTNAME chmod 600 /swapfile | |
docker-machine ssh $HOSTNAME mkswap /swapfile | |
docker-machine ssh $HOSTNAME swapon /swapfile | |
docker-machine ssh $HOSTNAME swapon -s | |
docker-machine ssh $HOSTNAME sudo bash -c 'echo "/swapfile none swap sw 0 0" >> /etc/fstab' | |
docker-machine ssh $HOSTNAME sysctl vm.swappiness=10 | |
docker-machine ssh $HOSTNAME sudo bash -c 'echo "vm.swappiness=10" >> /etc/sysctl.conf' | |
docker-machine ssh $HOSTNAME sysctl vm.vfs_cache_pressure=50 | |
docker-machine ssh $HOSTNAME sudo bash -c 'echo "vm.vfs_cache_pressure = 50" >> /etc/sysctl.conf' | |
echo $PUBLIC_KEYS | docker-machine ssh $HOSTNAME sudo bash -c 'cat >> /root/.ssh/authorized_keys' &&\ | |
docker-machine ip $HOSTNAME |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment