Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Added support for _FILE pattern in Docker Compose secrets #3781

Draft
wants to merge 4 commits into
base: mealie-next
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions docker/entry.sh
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,45 @@ init() {
. /opt/pysetup/.venv/bin/activate
}

load_secrets() {
# Each of these environment variables will support a `_FILE` suffix that allows
# for setting the environment variable through the Docker Compose secret
# pattern.
local -a secret_supported_vars=(
"POSTGRES_USER"
"POSTGRES_PASSWORD"
"POSTGRES_SERVER"
"POSTGRES_PORT"
"POSTGRES_DB"
"POSTGRES_URL_OVERRIDE"

"SMTP_HOST"
"SMTP_PORT"
"SMTP_USER"
"SMTP_PASSWORD"

"LDAP_SERVER_URL"
"LDAP_QUERY_PASSWORD"

"OIDC_CONFIGURATION_URL"
"OIDC_CLIENT_ID"

"OPENAI_BASE_URL"
"OPENAI_API_KEY"
)

# If any secrets are set, prefer them over base environment variables.
for var in "${secret_supported_vars[@]}"; do
file_var="${var}_FILE"
if [ -n "${!file_var}" ]; then
export "$var=$(<"${!file_var}")"
fi
done
}

change_user
init
load_secrets

# Start API
HOST_IP=`/sbin/ip route|awk '/default/ { print $3 }'`
Expand Down
Loading
Loading