-
Notifications
You must be signed in to change notification settings - Fork 32
Expand file tree
/
Copy pathdocker-entrypoint.sh
More file actions
executable file
·32 lines (25 loc) · 1.01 KB
/
docker-entrypoint.sh
File metadata and controls
executable file
·32 lines (25 loc) · 1.01 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
25
26
27
28
29
30
31
32
#!/usr/bin/env bash
set -e
set -u # unset variables throw error
set -o pipefail # pipes fail when partial command fails
bundle update --bundler
# Note: make sure env $DATABASE_* items are set!
# Attempt connect to db and if
# it fails, then assume db does not exist and
# db creation should be executed:
if PGPASSWORD=$DATABASE_PASSWORD psql -lqt -U$DATABASE_USER -h$DATABASE_HOST | cut -d \| -f 1 | grep -q civic; then
echo "civic database already exists. Skipping database initialisation."
else
echo "Creating civic database"
rake db:create
echo "Initializing civic database"
rake db:structure:load
echo "Loading a recent database backup"
# unpack ./db/data.sql.gz (required before loading data dump):
gunzip ./db/data.sql.gz
# load the sanitized version of a recent database backup found in ./db:
rake civic:load[force]
echo "Done"
fi
echo "Starting server now. You can test it with e.g. http://localhost:3000/api/genes/3845?identifier_type=entrez_id"
rails server -b 0.0.0.0