Skip to content

Commit 985f8fe

Browse files
committed
bitnami override
1 parent e9a25c3 commit 985f8fe

3 files changed

Lines changed: 55 additions & 0 deletions

File tree

Dockerfile

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,5 +149,10 @@ ENV PROXY_CONNECT_SEND_TIMEOUT="60s"
149149
# Allow disabling IPV6 resolution, default to false
150150
ENV DISABLE_IPV6="false"
151151

152+
# Bitnami dockerhub overrides
153+
ENV BITNAMI_DOCKERHUB_ANONYMOUS_OVERRIDE="false"
154+
ENV BITNAMI_HOST=""
155+
ENV BITNAMI_LEGACY_DOCKERHUB_ANONYMOUS_REWRITE="false"
156+
152157
# Did you want a shell? Sorry, the entrypoint never returns, because it runs nginx itself. Use 'docker exec' if you need to mess around internally.
153158
ENTRYPOINT ["/entrypoint.sh"]

entrypoint.sh

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -399,6 +399,55 @@ fi
399399
# Set worker processes if provided
400400
sed -i "s/worker_processes auto;/worker_processes ${WORKER_PROCESSES};/g" /etc/nginx/nginx.conf
401401

402+
echo "" > /etc/nginx/nginx.manifest.override.conf
403+
if [[ "a${BITNAMI_DOCKERHUB_ANONYMOUS_OVERRIDE}" == "atrue" && ${BITNAMI_HOST} != "" ]]; then
404+
cat << EOD >> /etc/nginx/nginx.manifest.override.conf
405+
map \$uri \$cond_uri {
406+
default 0;
407+
~bitnami 1;
408+
}
409+
map \$host \$cond_host {
410+
default 0;
411+
~\.docker\.io$ 1;
412+
}
413+
map \$http_authorization \$cond_auth {
414+
"" 1;
415+
default 0;
416+
}
417+
map "\$cond_uri\$cond_host$cond_auth" \$override {
418+
default 0;
419+
"111" 1;
420+
}
421+
if (\$override) {
422+
set \$targetHost "${BITNAMI_HOST}";
423+
}
424+
EOD
425+
fi
426+
427+
if [[ "a${BITNAMI_LEGACY_DOCKERHUB_ANONYMOUS_REWRITE}" == "atrue" ]]; then
428+
cat << EOD >> /etc/nginx/nginx.manifest.override.conf
429+
map \$uri \$cond_uri {
430+
default 0;
431+
~bitnami 1;
432+
}
433+
map \$host \$cond_host {
434+
default 0;
435+
~\.docker\.io$ 1;
436+
}
437+
map \$http_authorization \$cond_auth {
438+
"" 1;
439+
default 0;
440+
}
441+
map "\$cond_uri\$cond_host\$cond_auth" \$override {
442+
default 0;
443+
"111" 1;
444+
}
445+
if (\$override) {
446+
rewrite ^/v2/(.*)bitnami(.*)$ /v2/\$1bitnamilegacy\$2 break;
447+
}
448+
EOD
449+
fi
450+
402451
echo -e "\nFinal resolver configuration: ---"
403452
cat "${confpath}"
404453
echo -e "---\n"

nginx.manifest.common.conf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
# nginx config fragment included in every manifest-related location{} block.
2+
include "/etc/nginx/nginx.manifest.override.conf";
23
add_header X-Docker-Registry-Proxy-Cache-Upstream-Status "$upstream_cache_status";
34
add_header X-Docker-Registry-Proxy-Cache-Type "$docker_proxy_request_type";
45
proxy_pass https://$targetHost;

0 commit comments

Comments
 (0)