muyu-apiserver/deploy/entrypoint.sh
Chever John a5b1b406ea security: remove hardcoded credentials and add envsubst for go-zero configs
- Clear default passwords in all service configs and local dev YAMLs
- Add entrypoint.sh with envsubst to resolve ${ENV} vars in go-zero YAML
- Update Dockerfiles to install gettext and use entrypoint
- Update docker-compose to pass secrets via environment and require via ${VAR:?...}
- Add .gitignore rules for .env files, add .env.example template

Co-Authored-By: Claude <noreply@anthropic.com>
2026-06-17 23:16:28 +08:00

28 lines
698 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.
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" "$@"