Created
April 6, 2020 21:45
-
-
Save logankeenan/2f631a6e5a1ed786a18e78e9c2890d9d 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
| #!/usr/bin/env bash | |
| development_database=app_name_development | |
| test_database=app_name_test | |
| function startLocalPostgresInstanceWithDocker() { | |
| name=$1 | |
| port=$2 | |
| docker run --name ${name} -e POSTGRES_DB=${name} -d -p ${port}:5432 postgres | |
| } | |
| function instanceIsAlreadyRunning() { | |
| name=$1 | |
| docker ps | grep ${name} | |
| } | |
| function dockerContainerHasAlreadyBeenMade() { | |
| name=$1 | |
| docker ps -a | grep ${name} | |
| } | |
| if ! instanceIsAlreadyRunning ; then | |
| if dockerContainerHasAlreadyBeenMade ${development_database} ; then | |
| docker start ${development_database} | |
| else | |
| startLocalPostgresInstanceWithDocker ${development_database} 8081 | |
| fi | |
| if dockerContainerHasAlreadyBeenMade ${test_database} ; then | |
| docker start ${test_database} | |
| else | |
| startLocalPostgresInstanceWithDocker ${test_database} 8082 | |
| fi | |
| fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment