-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocker-entrypoint.sh
More file actions
executable file
·37 lines (31 loc) · 1.7 KB
/
Copy pathdocker-entrypoint.sh
File metadata and controls
executable file
·37 lines (31 loc) · 1.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#!/usr/bin/env bash
set -euo pipefail
CONFIG_FILE="/CLIProxyAPI/config/config.yaml"
TEMPLATE_FILE="/CLIProxyAPI/config.template.yaml"
# First start: render config.yaml from the template using CLIPROXY_* env vars.
# If a config already exists (user-provided or from a previous run), it is
# used as-is and the environment variables are ignored.
if [[ ! -f "${CONFIG_FILE}" ]]; then
if [[ -z "${CLIPROXY_API_KEY:-}" ]]; then
echo "ERROR: CLIPROXY_API_KEY is not set and no config file exists at ${CONFIG_FILE}." >&2
echo "Generate one with: openssl rand -hex 32" >&2
echo "Then pass it via -e CLIPROXY_API_KEY=... or the compose .env file." >&2
exit 1
fi
export CLIPROXY_HOST="${CLIPROXY_HOST:-}"
export CLIPROXY_PORT="${CLIPROXY_PORT:-8317}"
export CLIPROXY_DEBUG="${CLIPROXY_DEBUG:-false}"
export CLIPROXY_LOGGING_TO_FILE="${CLIPROXY_LOGGING_TO_FILE:-true}"
export CLIPROXY_ALLOW_REMOTE_MANAGEMENT="${CLIPROXY_ALLOW_REMOTE_MANAGEMENT:-false}"
export CLIPROXY_MANAGEMENT_KEY="${CLIPROXY_MANAGEMENT_KEY:-}"
export CLIPROXY_API_KEY
echo "No config found — rendering ${CONFIG_FILE} from template."
envsubst '${CLIPROXY_HOST} ${CLIPROXY_PORT} ${CLIPROXY_API_KEY} ${CLIPROXY_DEBUG} ${CLIPROXY_LOGGING_TO_FILE} ${CLIPROXY_ALLOW_REMOTE_MANAGEMENT} ${CLIPROXY_MANAGEMENT_KEY}' \
< "${TEMPLATE_FILE}" > "${CONFIG_FILE}"
chmod 600 "${CONFIG_FILE}"
fi
# The binary's default config path is /CLIProxyAPI/config.yaml; ours lives in
# the mounted config/ directory. Symlink so subcommands run via `docker exec`
# (e.g. --claude-login) find it without an explicit --config flag.
ln -sf "${CONFIG_FILE}" /CLIProxyAPI/config.yaml
exec /CLIProxyAPI/CLIProxyAPI "$@"