-
Notifications
You must be signed in to change notification settings - Fork 130
/
chp-docker-entrypoint
executable file
·44 lines (37 loc) · 1.2 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
#!/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" -a -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'
case "$@" in
*"--api-ip"*)
break ;;
*)
# Default api-ip to all interfaces in docker,
# so that it is accessible to other containers
# and when port-forwarding is requested.
ARGS="--api-ip=0.0.0.0" ;;
esac
exec configurable-http-proxy $ARGS "$@"