Last active
December 20, 2015 20:28
-
-
Save jipiboily/6190215 to your computer and use it in GitHub Desktop.
Bootstrap script for Dokku + postgres 9.1. Also creates a .pgpass and creates a database
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
# Tested on Ubuntu 13.04 x64 | |
# You need to set those environment variables | |
#``` | |
# export DATABASE_USER=username_here | |
# export DATABASE_PASSWORD=password_here | |
# export DATABASE_NAME=database_name_here | |
# export DATABASE_ROOT_PASSWORD=database_root_password | |
# ``` | |
# ON SERVER | |
# Install prerequisites | |
apt-get install postgresql-client-9.1 -y | |
# Install dokku | |
wget -qO- https://raw.github.com/progrium/dokku/master/bootstrap.sh | sudo bash | |
# Install pg (9.1) | |
PGSQL=$(docker run -p 5432 -d synthomat/pgsql /usr/bin/start_pgsql.sh $DATABASE_ROOT_PASSWORD) | |
DATABASE_IP=$(docker inspect $PGSQL | grep IPAddress | awk '{ print $2 }' | tr -d ',"') | |
echo "Database IP: $DATABASE_IP" | |
# Create .pgpass | |
echo "$DATABASE_IP:5432:$DATABASE_NAME:$DATABASE_USER:$DATABASE_PASSWORD" > ~/.pgpass | |
echo "$DATABASE_IP:5432:postgres:root:$DATABASE_ROOT_PASSWORD" >> ~/.pgpass | |
chmod 600 ~/.pgpass | |
sleep 5 | |
# Create DB, user and role | |
createdb --username=root -h $DATABASE_IP $DATABASE_NAME | |
createuser --login --username=root -h $DATABASE_IP $DATABASE_USER |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment