-
Notifications
You must be signed in to change notification settings - Fork 1
/
chp-docker-entrypoint
executable file
·48 lines (40 loc) · 1.31 KB
/
chp-docker-entrypoint
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
38
39
40
41
42
43
44
45
46
47
48
#!/bin/sh
# Wrapper around CHP entrypoint that changes defaults slightly
# to be more appropriate when run in a container.
# usage: file_env VAR [DEFAULT]
# ie: file_env 'XYZ_DB_PASSWORD' 'example'
# (will allow for "$XYZ_DB_PASSWORD_FILE" to fill in the value of
# "$XYZ_DB_PASSWORD" from a file, especially for Docker's secrets feature)
file_env() {
var=$1
file_var="${var}_FILE"
var_value=$(printenv "$var" || true)
file_var_value=$(printenv "$file_var" || true)
default_value=$2
if [ -n "$var_value" ] && [ -n "$file_var_value" ]; then
echo >&2 "error: both $var and $file_var are set (but are exclusive)"
exit 1
fi
if [ -z "${var_value}" ]; then
if [ -z "${file_var_value}" ]; then
export "${var}"="${default_value}"
else
export "${var}"="$(cat "$file_var_value")"
fi
fi
unset "$file_var"
}
file_env 'CONFIGPROXY_AUTH_TOKEN'
set_api_ip=true
for arg in "$@"; do
case "$arg" in
"--api-ip"* | "help" | "-h" | "--help" | "version" | "completion") set_api_ip=false ;;
esac
done
# Default api-ip to all interfaces in docker,
# so that it is accessible to other containers
# and when port-forwarding is requested.
if [ $set_api_ip = true ]; then
ARGS="--api-ip=0.0.0.0"
fi
exec configurable-http-proxy "$@" "$ARGS"