-
-
Save johnkraczek/6035216 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 | |
# 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: [email protected] | |
# 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." | |
echo "Creating the treeio database..." | |
# Sleep for a second to give it a chance to spin up | |
sleep 1 | |
createdb -U postgres --host localhost --port $PG_PORT -e treeio | |
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