forked from superplanehq/superplane
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocker-entrypoint.sh
More file actions
24 lines (18 loc) · 1.07 KB
/
docker-entrypoint.sh
File metadata and controls
24 lines (18 loc) · 1.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#!/usr/bin/env bash
set -euo pipefail
IFS=$'\n\t'
if [ -z $DB_PASSWORD ]; then echo "DB username not set" && exit 1; fi
if [ -z $DB_HOST ]; then echo "DB host not set" && exit 1; fi
if [ -z $DB_PORT ]; then echo "DB port not set" && exit 1; fi
if [ -z $DB_USERNAME ]; then echo "DB username not set" && exit 1; fi
if [ -z $DB_NAME ]; then echo "DB name not set" && exit 1; fi
if [ -z $APPLICATION_NAME ]; then echo "Application name not set" && exit 1; fi
[ "${POSTGRES_DB_SSL}" = "true" ] && export PGSSLMODE=require || export PGSSLMODE=disable
echo "Creating DB..."
PGPASSWORD=${DB_PASSWORD} createdb -h ${DB_HOST} -p ${DB_PORT} -U ${DB_USERNAME} ${DB_NAME} || true
echo "Migrating DB..."
DB_URL="postgres://${DB_USERNAME}:${DB_PASSWORD}@${DB_HOST}:${DB_PORT}/${DB_NAME}?sslmode=${PGSSLMODE}"
migrate -source file:///app/db/migrations -database ${DB_URL} up
migrate -source file:///app/db/data_migrations -database ${DB_URL}\&x-migrations-table=data_migrations up
echo "Starting server..."
/app/build/superplane