Pass app variables as KEY: ${KEY} so they merge with compose-set values

The env override listed bare keys (- KEY). podman-compose can't merge a
bare key with a value the compose file sets for the same variable and
fails the deploy: "can't merge value of [KEY] of type str and NoneType".
Writing KEY: ${KEY} keeps values out of the YAML (compose interpolates
them from its environment) and merges with list- or map-form environment.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013FYo6JSV1fDU1fm3LU77iF
This commit is contained in:
agent 2026-10-09 22:25:32 +00:00
parent ba0a0155c8
commit a5f06d4490
2 changed files with 11 additions and 7 deletions

View file

@ -279,8 +279,11 @@ load_app_env() {
# (Re)generate the env override before containers are created. Variables are
# always available for ${VAR} interpolation; with APP_ENV_INJECT (default true)
# every service also receives them. Bare keys make compose read the values from
# its own environment, so values never have to be quoted into YAML.
# every service also receives them as `KEY: ${KEY}`, which compose fills in from
# its own environment, so values never have to be quoted into YAML. (Bare keys
# would do the same, but podman-compose can't merge a bare key with a value the
# compose file sets for the same variable: "can't merge value of [KEY] of type
# str and NoneType".)
prepare_env_override() {
local name="$1"
local override services svc key tmp
@ -303,7 +306,7 @@ prepare_env_override() {
[[ "${svc}" =~ ^[A-Za-z0-9._-]+$ ]] || continue
printf ' "%s":\n environment:\n' "${svc}"
for key in "${APP_ENV_KEYS[@]}"; do
printf ' - %s\n' "${key}"
printf ' %s: ${%s}\n' "${key}" "${key}"
done
done <<<"${services}"
} >"${tmp}"