🐛 Fix entrypoint when AUTH_REGISTRIES is empty

pull/16/head
Sebastián Ramírez 2019-08-09 18:53:09 -05:00
parent 4e5e75e91d
commit df8c057855
1 changed files with 27 additions and 24 deletions

View File

@ -34,18 +34,20 @@ export ALLDOMAINS=${ALLDOMAINS:1} # remove the first comma and export
# Now handle the auth part. # Now handle the auth part.
echo -n "" > /etc/nginx/docker.auth.map echo -n "" > /etc/nginx/docker.auth.map
# Ref: https://stackoverflow.com/a/47633817/219530 # Only configure auth registries if the env var contains values
AUTH_REGISTRIES_DELIMITER=${AUTH_REGISTRIES_DELIMITER:-" "} if [ "$AUTH_REGISTRIES" ]; then
s=$AUTH_REGISTRIES$AUTH_REGISTRIES_DELIMITER # Ref: https://stackoverflow.com/a/47633817/219530
auth_array=(); AUTH_REGISTRIES_DELIMITER=${AUTH_REGISTRIES_DELIMITER:-" "}
while [[ $s ]]; do s=$AUTH_REGISTRIES$AUTH_REGISTRIES_DELIMITER
auth_array=();
while [[ $s ]]; do
auth_array+=( "${s%%"$AUTH_REGISTRIES_DELIMITER"*}" ); auth_array+=( "${s%%"$AUTH_REGISTRIES_DELIMITER"*}" );
s=${s#*"$AUTH_REGISTRIES_DELIMITER"}; s=${s#*"$AUTH_REGISTRIES_DELIMITER"};
done done
AUTH_REGISTRY_DELIMITER=${AUTH_REGISTRY_DELIMITER:-":"} AUTH_REGISTRY_DELIMITER=${AUTH_REGISTRY_DELIMITER:-":"}
for ONEREGISTRY in "${auth_array[@]}"; do for ONEREGISTRY in "${auth_array[@]}"; do
s=$ONEREGISTRY$AUTH_REGISTRY_DELIMITER s=$ONEREGISTRY$AUTH_REGISTRY_DELIMITER
registry_array=(); registry_array=();
while [[ $s ]]; do while [[ $s ]]; do
@ -59,7 +61,8 @@ for ONEREGISTRY in "${auth_array[@]}"; do
AUTH_BASE64=$(echo -n "${AUTH_USER}:${AUTH_PASS}" | base64 | tr -d \\n ) AUTH_BASE64=$(echo -n "${AUTH_USER}:${AUTH_PASS}" | base64 | tr -d \\n )
echo "Adding Auth for registry '${AUTH_HOST}' with user '${AUTH_USER}'." echo "Adding Auth for registry '${AUTH_HOST}' with user '${AUTH_USER}'."
echo "\"${AUTH_HOST}\" \"${AUTH_BASE64}\";" >> /etc/nginx/docker.auth.map echo "\"${AUTH_HOST}\" \"${AUTH_BASE64}\";" >> /etc/nginx/docker.auth.map
done done
fi
echo "" > /etc/nginx/docker.verify.ssl.conf echo "" > /etc/nginx/docker.verify.ssl.conf
if [[ "a${VERIFY_SSL}" == "atrue" ]]; then if [[ "a${VERIFY_SSL}" == "atrue" ]]; then