Skip to content

Instantly share code, notes, and snippets.

@kjellski
Forked from funkotron/docker_create_treeio.sh
Created July 19, 2013 20:04
Show Gist options
  • Save kjellski/6041981 to your computer and use it in GitHub Desktop.
Save kjellski/6041981 to your computer and use it in GitHub Desktop.
#!/bin/bash
# Description: Using Docker (requires docker to be installed http://www.docker.io/gettingstarted/ ), spawn a postgresql instance and a dynamically configured treeio instance
# Author: Adam Awan
# Email: adam@tree.io
# Create a PostgreSQL Instance
echo "Retrieving jpetazzo/pglite PostgreSQL Container..."
docker pull jpetazzo/pglite
echo "Running jpetazzo/pglite PostgreSQL Container..."
PGID=$(docker run -d jpetazzo/pglite)
while ! docker logs $PGID 2>/dev/null | grep -q ^PG_PASSWORD= ; do sleep 1 ; done
eval $(docker logs $PGID 2>/dev/null)
PG_PORT=$(docker port $PGID 5432)
export PGPASSWORD=$PG_PASSWORD # Renaming variable for createdb access
PG_HOST=`ifconfig | grep "docker" -A 1 | grep "inet" | cut -d\: -f2 | cut -d\ -f1`
echo "A new PostgreSQL instance is listening at IP $PG_HOST on port $PG_PORT. The admin user is postgres, the admin password is $PG_PASSWORD."
# Sleep for a second to give it a chance to spin up
sleep 1
echo "Pulling the treeio container..."
docker pull adam/treeio
# The 5000 in the following line maps the port to forward for treeio
echo "Running treeio on port 80"
echo "If running Vagrant you will need to forward port 80"
TREEID=$(docker run -d -p 22 -p 80:5000 adam/treeio /usr/sbin/treeio $PG_HOST $PG_PORT $PG_PASSWORD)
SSHPORT=$(docker port $TREEID 22)
echo "treeio running with container ID $TREEID"
echo "treeio SSH running on port $SSHPORT"
echo "WARNING! You must change the root password of your treeio container - currently it is 'treeio'."
echo "You can ssh to your container by running: ssh -p $SSHPORT root@localhost"
echo "Once connected run passwd to change your password."
echo "treeio is running at http://localhost with username 'admin' and password 'admin'."
echo "Container setup complete."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment