The entrypoint.sh was writing the rendered config back to the same directory as the source, which fails when the config is mounted from a Kubernetes ConfigMap (read-only filesystem). Write to /tmp instead. Co-Authored-By: Claude <noreply@anthropic.com>
29 lines
769 B
Bash
Executable File
29 lines
769 B
Bash
Executable File
#!/bin/sh
|
|
# Substitute environment variables in YAML config templates before starting the service.
|
|
# Usage: entrypoint.sh <binary> -f <config.yaml>
|
|
#
|
|
# 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 <config> 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
|