Skip to content

Instantly share code, notes, and snippets.

@vonglasow
Forked from bradleyboy/create_koken.sh
Last active June 15, 2016 11:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vonglasow/c5dff0ac7a83e57a53f4dd653144533f to your computer and use it in GitHub Desktop.
Save vonglasow/c5dff0ac7a83e57a53f4dd653144533f to your computer and use it in GitHub Desktop.
Docker script for Koken
#!/bin/bash
echo ""
# Root check
if [[ "$UID" -ne 0 ]]; then
echo "!! This script requires root privileges. sudo ./create_koken.sh"
echo ""
exit
fi
echo -n "=> Pulling Docker/Koken image (this may take a few minutes)..."
docker pull koken/koken-lemp > /dev/null
echo "done."
KOKEN_DIR="/var/www/koken"
echo -n "=> Creating $KOKEN_DIR/www and $KOKEN_DIR/mysql for persistent storage..."
mkdir -p $KOKEN_DIR/www
mkdir -p $KOKEN_DIR/mysql
#mkdir -p $KOKEN_DIR/nginx/sites-available
echo "done."
echo "=> Starting Docker container..."
#CID=$(docker run --name=photos-koken --restart=always -p 8080:8080 -v $KOKEN_DIR/www:/usr/share/nginx/www -v $KOKEN_DIR/mysql:/var/lib/mysql -v $KOKEN_DIR/nginx/sites-available:/etc/nginx/sites-available -d koken/koken-lemp /sbin/my_init)
CID=$(docker run --name=photos-koken --restart=always -p 8080:8080 -v $KOKEN_DIR/www:/usr/share/nginx/www -v $KOKEN_DIR/mysql:/var/lib/mysql -d koken/koken-lemp /sbin/my_init)
echo -n "=> Waiting for Koken to become available.."
RET=0
while [[ RET -lt 1 ]]; do
IP=$(docker inspect $CID | grep IPAddress | cut -d '"' -f 4)
echo -n "."
sleep 5
RET=$(curl -s http://$IP:8080 | grep "jquery" | wc -l)
done
echo "done."
echo "=> Ready! Load this server's IP address or domain in a browser to begin using Koken."
echo ""
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment