-
Notifications
You must be signed in to change notification settings - Fork 1
/
entrypoint.sh
executable file
·40 lines (31 loc) · 882 Bytes
/
entrypoint.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
28
29
30
31
32
33
34
35
36
37
38
39
40
#!/bin/bash
# Only used in development as an entrypoint for the Docker container
set -e
# Ensure the dependencies are installed
mix deps.get
if [[ -f assets/package.json ]]; then
# Install frontend dependencies with npm
cd assets
npm install
cd ..
fi
echo
# Wait until Postgres is ready
while ! pg_isready -q -h $POSTGRES_HOST -p 5432 -U $POSTGRES_USER
do
echo "$(date) - waiting for database to start"
sleep 2
done
export PGPASSWORD=$POSTGRES_PASSWORD
# Create, migrate, and seed database if it doesn't exist.
if psql -lqt -U $POSTGRES_USER -h $POSTGRES_HOST | cut -d \| -f 1 | grep -qw $POSTGRES_DB; then
echo "Database $POSTGRES_DB exists."
else
echo "Database $POSTGRES_DB does not exist. Creating..."
mix ecto.create
mix ecto.migrate
mix run priv/repo/seeds.exs
echo "Database $POSTGRES_DB created."
fi
# Start the Phoenix server
mix phx.server