#!/bin/sh # Substitute environment variables in YAML config templates before starting the service. # Usage: entrypoint.sh -f # # The YAML file is treated as a template with ${VAR} placeholders. # envsubst replaces them with actual environment variable values at container start time. # The rendered config is written to /tmp to avoid read-only filesystem issues (e.g. ConfigMap mounts). set -e BINARY="$1" shift # Scan args for -f and render to /tmp ARGS="" PREV="" for arg in "$@"; do if [ "$PREV" = "-f" ] && [ -f "$arg" ]; then RENDERED="/tmp/$(basename "$arg")" envsubst < "$arg" > "$RENDERED" ARGS="$ARGS $RENDERED" else ARGS="$ARGS $arg" fi PREV="$arg" done exec "$BINARY" $ARGS