forked from AlexsLemonade/refinebio
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun_postgres.sh
executable file
·27 lines (24 loc) · 1005 Bytes
/
run_postgres.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#! /bin/bash
# This script should always run as if it were being called from
# the directory it lives in.
script_directory=`perl -e 'use File::Basename;
use Cwd "abs_path";
print dirname(abs_path(@ARGV[0]));' -- "$0"`
cd $script_directory
# CircleCI Docker won't make this by default for some reason
VOLUMES=$script_directory/volumes_postgres
if [ ! -d $VOLUMES ]; then
mkdir $VOLUMES
fi
# Check if a docker database named "drdb" exists, and if so just run it
if [[ $(docker ps -a --filter name=drdb -q) ]]; then
docker start drdb > /dev/null
echo "Started database."
# Otherwise, install it from docker hub
else
# via https://hub.docker.com/_/postgres/
# 9.6.6 is the current (as of Jan 23 2018) RDS most recent version.
# Password can be exposed to git/CI because this is only for dev/testing purposes, not real data.
echo "Installing database..."
docker run -p 5432:5432 --name drdb -v "$VOLUMES":/var/lib/postgresql/data -e POSTGRES_PASSWORD=mysecretpassword -d postgres:9.6.6
fi