loomio/entrypoint.sh

39 lines
886 B
Bash
Raw Permalink Normal View History

2023-03-14 19:31:55 +00:00
#!/usr/bin/env bash
file_env() {
# 3wc: Load $VAR_FILE into $VAR - useful for secrets. See
# https://medium.com/@adrian.gheorghe.dev/using-docker-secrets-in-your-environment-variables-7a0609659aab
local var="$1"
local fileVar="${var}_FILE"
local def="${2:-}"
if [ "${!var:-}" ] && [ "${!fileVar:-}" ]; then
echo >&2 "error: both $var and $fileVar are set (but are exclusive)"
exit 1
fi
local val="$def"
if [ "${!var:-}" ]; then
val="${!var}"
elif [ "${!fileVar:-}" ]; then
val="$(< "${!fileVar}")"
fi
export "$var"="$val"
unset "$fileVar"
}
file_env "DEVISE_SECRET"
file_env "SECRET_COOKIE_TOKEN"
2022-02-08 16:09:18 +00:00
if test ! -f /loomio/storage/migrations_ran; then
echo "first deploy, running migrations..."
rake db:setup
touch /loomio/storage/migrations_ran
fi
2023-04-27 18:53:37 +00:00
if [ -n "$1" ]; then
echo "Running '$1'"
$1
else
echo "starting loomio!"
/loomio/docker_start.sh
fi