From 9769ea1ba4aaa194f5df23138394558e4d501d85 Mon Sep 17 00:00:00 2001 From: Stephan Schnabel Date: Tue, 24 Jun 2025 21:12:16 +0200 Subject: [PATCH] Add option to source env from file --- README.md | 1 + entrypoint.sh | 9 +++++++++ 2 files changed, 10 insertions(+) diff --git a/README.md b/README.md index 56eea68..f042d9e 100644 --- a/README.md +++ b/README.md @@ -86,6 +86,7 @@ docker run --rm --user=$(id -u) --volume=$HOME:$HOME:ro --workdir=$PWD --env=PLU | `annotation` | PLUGIN_ANNOTATION | `none` | Annotations (also known as labels) to add to image | | `push` | PLUGIN_PUSH | `true` | Push images if output names are set. | | `auth` | PLUGIN_AUTH | `none` | Auth for private registries | +| `env-file` | PLUGIN_ENV_FILE | `none` | Source environment values from given file | ## Alternatives diff --git a/entrypoint.sh b/entrypoint.sh index 21b3ea9..c13fbc3 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -5,6 +5,15 @@ set -eu; ## check input ## +if [[ -n "${PLUGIN_ENV_FILE:-}" ]]; then + if [[ ! -f "PLUGIN_ENV_FILE" ]]; then + echo "Env file $PLUGIN_ENV_FILE not found." + exit 1 + fi + # shellcheck source=/dev/null + source "$PLUGIN_ENV_FILE" +fi + BUILDCTL_CONTEXT=${PLUGIN_CONTEXT:-$(pwd)} BUILDCTL_DOCKERFILE=$(dirname "${PLUGIN_DOCKERFILE:-$BUILDCTL_CONTEXT/Dockerfile}") if [[ ! -f $BUILDCTL_DOCKERFILE/Dockerfile ]]; then