-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathentrypoint.sh
More file actions
executable file
·61 lines (50 loc) · 1.76 KB
/
entrypoint.sh
File metadata and controls
executable file
·61 lines (50 loc) · 1.76 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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#!/bin/bash
export PGPORT="${DB_PORT:=$PGPORT}"
export PGHOST="${DB_HOST:=$PGHOST}"
export PGUSER="${DB_USER:=$PGUSER}"
export PGPASSWORD="${DB_PASS:=$PGPASSWORD}"
export PGDATABASE="${DB_NAME:=$PGDATABASE}"
export DATABASE_URL="${DATABASE_URL:=ecto://${DB_USER:=$PGUSER}:${DB_PASS:=$PGPASSWORD}@${DB_HOST:=$PGHOST}:${DB_PORT:=$PGPORT}/${DB_NAME:=$PGDATABASE}}"
export MIX_ENV="${MIX_ENV:=dev}"
if [[ $MIX_ENV == "prod" ]]; then
export NODE_ENV=production
else
export NODE_ENV=development
fi
sudo /usr/local/bin/sanitize
cd $APP_HOME
if [ ! -f mix.exs ]; then
source /project_initialization_methods.sh
if [ ! "$GIT_SOURCE" == "" ]; then
echo "Fetching phoenix project..."
git clone --recurse-submodules "$GIT_SOURCE" .
else
generate_phoenix_project
fi
echo "Fetching elixir dependencies..."
mix deps.get &>/dev/null
echo "Fetching node $NODE_ENV dependencies..."
(cd assets && npm install &>/dev/null && node node_modules/webpack/bin/webpack.js --mode $NODE_ENV &>/dev/null)
if [[ ! -e ./priv/cert ]] || [ "$MIX_ENV" == "dev" ]; then
echo "Generating self-signed certs..."
mix phx.gen.cert &>/dev/null
echo "# Ignore generated SSL certificates" >>.gitignore
echo "/priv/cert/" >>.gitignore
fi
generate_secrets_if_undefined
echo "Done"
fi
if [ "$MIX_ENV" == "prod" ]; then
mix deps.get --only "$MIX_ENV"
npm run deploy --prefix ./assets
fi
if [ ! "$DB_NAME" == "" ]; then
mix ecto.setup
mix ecto.migrate
fi
mix compile
if [[ ! -e ./priv/static ]]; then
(cd assets && npm install &>/dev/null && node node_modules/webpack/bin/webpack.js --mode $NODE_ENV &>/dev/null)
fi
mix phx.digest
exec elixir --name "${ERLANG_NAME:-app}@${ERLANG_DOMAIN:-${DOMAIN:-${HOSTNAME:-localhost}}}" --cookie "${ERLANG_COOKIE:-app}" -S mix phx.server