Skip to content

Commit 9db22a6

Browse files
Merge pull request #7 from Scalingo/fix/docker/upstreams
fix(docker): upstream_registries envvar in docker entrypoint
2 parents a629084 + a933812 commit 9db22a6

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

entrypoint.sh

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ echo -n "" >/opt/openresty/nginx/conf/docker.targetHost.map
6262
echo -n "" >/opt/openresty/nginx/conf/docker.auth.map
6363

6464
# Only configure auth registries if the env var contains values
65-
if [ "$AUTH_REGISTRIES" ]; then
65+
if [[ ${AUTH_REGISTRIES+x} ]]; then
6666
# Ref: https://stackoverflow.com/a/47633817/219530
6767
AUTH_REGISTRIES_DELIMITER=${AUTH_REGISTRIES_DELIMITER:-" "}
6868
s=$AUTH_REGISTRIES$AUTH_REGISTRIES_DELIMITER
@@ -84,9 +84,9 @@ if [ "$AUTH_REGISTRIES" ]; then
8484
AUTH_HOST="${registry_array[0]}"
8585
AUTH_USER="${registry_array[1]}"
8686
AUTH_PASS="${registry_array[2]}"
87-
AUTH_BASE64=$(echo -n ${AUTH_USER}:${AUTH_PASS} | base64 -w0 | xargs)
87+
AUTH_HASH=$(echo -n ${AUTH_USER}:${AUTH_PASS} | base64 -w0 | xargs)
8888
echo "Adding Auth for registry '${AUTH_HOST}' with user '${AUTH_USER}'."
89-
echo "\"${AUTH_HOST}\" \"${AUTH_BASE64}\";" >>/opt/openresty/nginx/conf/docker.auth.map
89+
echo "\'${AUTH_HOST}\' \'${AUTH_HASH}\';" >>/opt/openresty/nginx/conf/docker.auth.map
9090
done
9191
fi
9292

@@ -167,7 +167,7 @@ else
167167
return 405 "DELETE method is not allowed";
168168
}
169169
EOF
170-
if [[ -v UPSTREAM_REGISTRIES ]]; then
170+
if [[ ${UPSTREAM_REGISTRIES+x} ]]; then
171171
UPSTREAM_REGISTRIES_DELIMITER=${UPSTREAM_REGISTRIES_DELIMITER:-" "}
172172
s=$UPSTREAM_REGISTRIES$UPSTREAM_REGISTRIES_DELIMITER
173173
upstream_array=()
@@ -201,7 +201,7 @@ EOF
201201
fi
202202

203203
# Only configure htpasswd if the env var exists
204-
if [[ -z ${HTPASSWD+set} ]]; then
204+
if [[ -z ${HTPASSWD+x} ]]; then
205205
echo "" >/opt/openresty/nginx/conf/htpasswd.conf
206206
else
207207
HTPASSWD_DELIMITER=${HTPASSWD_DELIMITER:-" "}

0 commit comments

Comments
 (0)