#!/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. set -e BINARY="$1" shift CONFIG_FILE="" for arg in "$@"; do case "$prev" in -f) CONFIG_FILE="$arg" ;; esac prev="$arg" done if [ -n "$CONFIG_FILE" ] && [ -f "$CONFIG_FILE" ]; then # Replace ${VAR} placeholders with environment variable values envsubst < "$CONFIG_FILE" > "${CONFIG_FILE}.tmp" mv "${CONFIG_FILE}.tmp" "$CONFIG_FILE" fi exec "$BINARY" "$@"