-
Notifications
You must be signed in to change notification settings - Fork 75
/
pre-deploy
executable file
·39 lines (31 loc) · 1.26 KB
/
pre-deploy
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
28
29
30
31
32
33
34
35
36
37
38
39
#!/bin/bash
set -e;
APP="$1"
PG_APP_IMAGE="postgresql/$APP"
# Check if an existing DB volume exists
PG_APP_IMAGE_ID=$(docker images | grep "$PG_APP_IMAGE" | awk '{print $3}')
if [[ -n $PG_APP_IMAGE_ID ]]; then
echo "-----> Checking status of PostgreSQL"
# Check if DB container is installed
PG_IMAGE=$(docker images | grep "kloadut/postgresql " | awk '{print $3}')
if [[ -z $PG_IMAGE ]]; then
echo "PostgreSQL image not found... Did you run 'dokku plugins-install' ?"
exit 1
fi
echo " Found image postgresql/$APP database"
echo -n " Checking status... "
PG_APP_CONTAINER_ID=$(docker ps | grep "$PG_APP_IMAGE" | awk '{print $1}')
if [[ -n $PG_APP_CONTAINER_ID ]]; then
echo "ok."
else
echo "stopped."
PG_VOLUME="`cat $DOKKU_ROOT/.postgresql/volume_$APP`:/opt/postgresql"
echo -n " Launching $PG_APP_IMAGE... "
echo "COMMAND: docker run -v $PG_VOLUME -p 5432 -d $PG_APP_IMAGE /usr/bin/start_pgsql.sh $DB_PASSWORD"
ID=$(docker run -v $PG_VOLUME -p 5432 -d $PG_APP_IMAGE /usr/bin/start_pgsql.sh $DB_PASSWORD)
echo "COMMAND: docker postgresql:link $APP $APP"
dokku postgresql:link $APP $APP
sleep 1
echo "ok."
fi
fi