From 57350924a54fe499cf6a2c1e8007497d5cd2500b Mon Sep 17 00:00:00 2001 From: TonyBlu <101348912+TonyBlur@users.noreply.github.com> Date: Thu, 30 Apr 2026 20:51:01 +0800 Subject: [PATCH] Support loading env vars from .env files in container --- README.md | 4 ++++ docker-entrypoint.sh | 16 ++++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/README.md b/README.md index 5fbc971..29ed197 100644 --- a/README.md +++ b/README.md @@ -39,6 +39,10 @@ services: Certain values can be set via environment variables, using the `-e` parameter on the docker command line, or the `environment:` section in docker-compose. +You can also load variables from files: +* Docker CLI supports `--env-file /path/to/.env`. +* The container entrypoint auto-loads `/app/.env` if present, and also loads a custom file when `ENV_FILE` points to it. + ### ⬇️ Download Behavior * __MAX_CONCURRENT_DOWNLOADS__: Maximum number of simultaneous downloads allowed. For example, if set to `5`, then at most five downloads will run concurrently, and any additional downloads will wait until one of the active downloads completes. Defaults to `3`. diff --git a/docker-entrypoint.sh b/docker-entrypoint.sh index 5f07bc5..0010cb5 100644 --- a/docker-entrypoint.sh +++ b/docker-entrypoint.sh @@ -1,5 +1,21 @@ #!/bin/sh +load_env_file() { + env_file="$1" + if [ -f "$env_file" ]; then + echo "Loading environment from ${env_file}" + # shellcheck disable=SC1090 + set -a + . "$env_file" + set +a + fi +} + +load_env_file "/app/.env" +if [ -n "${ENV_FILE}" ]; then + load_env_file "${ENV_FILE}" +fi + PUID="${UID:-$PUID}" PGID="${GID:-$PGID}"