Move Rails secrets into Docker secrets
This commit is contained in:
+25
-2
@@ -1,10 +1,33 @@
|
||||
#! /bin/sh
|
||||
#!/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"
|
||||
|
||||
if test ! -f /loomio/storage/migrations_ran; then
|
||||
echo "first deploy, running migrations..."
|
||||
rake db:setup
|
||||
touch /loomio/storage/migrations_ran
|
||||
fi
|
||||
|
||||
echo "starting loomio!"
|
||||
/loomio/docker_start.sh
|
||||
|
||||
Reference in New Issue
Block a user