Skip to content

Instantly share code, notes, and snippets.

@wturnerharris
Last active August 29, 2015 14:18
Show Gist options
  • Save wturnerharris/43f910c3a09cdc52f1c3 to your computer and use it in GitHub Desktop.
Save wturnerharris/43f910c3a09cdc52f1c3 to your computer and use it in GitHub Desktop.
quick docker init script
#!/bin/bash
if [ $# -eq 0 ]; then
printf "===> Needs s fully-qualified git repo\n"
exit
fi
printf "===> Installing dependencies...\n"
apt-get install -y wget nano git
printf "===> Changing to webroot and copying/downloading WordPress...\n"
cd /var/www/html
wget https://wordpress.org/latest.tar.gz
tar -xzf latest.tar.gz
mv wordpress/* .
rm -rf wordpress latest.tar.gz
chown -R www-data:www-data /var/www/html
cd ../
printf "===> Cloning repo...\n"
git clone $1 clone
mv clone/.git html/.git
rm -rf clone/
cd html/
printf "===> Fetching all remotes...\n"
git fetch --all
git checkout $2
git reset --hard HEAD
mv wp-config-sample.php wp-config.php
printf "===> Setup wp-config, either manually or download via wget.\n\n"
printf " /** assuming root mysql user */\n"
printf " define('DB_PASSWORD', getenv('MYSQL_PORT_3306_TCP_ADDR')); \n"
printf " define('DB_HOST', getenv('MYSQL_ENV_MYSQL_ROOT_PASSWORD')); \n"
exit
@wturnerharris
Copy link
Author

Details

This script will...

  • download and install wordpress to the webroot (/var/www/html/)
  • clone and checkout the desired branch

First

first chmod +x wp_docker.sh

Usage

./wp_docker [repo] [branch]
Ex:
./wp_docker.sh https://username:password@path_to_git_repo branch_name

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment