loomio/entrypoint.sh
stevensting c6afdb09c0
All checks were successful
continuous-integration/drone/push Build is passing
move contents of loomios docker_start.sh to entrypoint.sh. unclear why this helps
2025-02-19 13:26:21 +01:00

44 lines
999 B
Bash

#!/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"
file_env "POSTGRES_PASSWORD"
file_env "SMTP_PASSWORD"
export DATABASE_URL="postgresql://${POSTGRES_USER}:${POSTGRES_PASSWORD}@db/${POSTGRES_DB}"
if [ -n "$1" ]; then
echo "Running '$1'"
$1
else
echo "starting loomio!"
if [ "$TASK" = "worker" ]; then
bundle exec sidekiq
else
bundle install
bundle exec rake db:prepare
bundle exec puma -C config/puma.rb
fi
fi