Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added Docker run option to inlcude credentials for private remote reg… #87

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion bin/entrypoint
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,20 @@ fi

if [ -n "${REGISTRY_URL}" ] ; then
sed -i "s,\${REGISTRY_URL},${REGISTRY_URL}," /etc/nginx/conf.d/default.conf
HOST=$(echo ${REGISTRY_URL} | sed "s,http[s]*://,,")
sed -i "s,\${HOST},${HOST}," /etc/nginx/conf.d/default.conf
sed -i "s,#!,," /etc/nginx/conf.d/default.conf

if [ -f ${CREDS_FILE} ] ; then
CREDENTIALS=$(cat ${CREDS_FILE} | tr -d \\n)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a brilliant idea to improve the security!

BASIC_AUTH=$(echo -n "${CREDENTIALS}" | base64 | tr -d \\n)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks better yes 😄 but I found a more generic way, a feature to add any header in the proxy pass

sed -i "s,\${BASIC_AUTH},${BASIC_AUTH}," /etc/nginx/conf.d/default.conf
sed -i "s,##,," /etc/nginx/conf.d/default.conf
fi
fi

if [ -z "$@" ]; then
nginx -g "daemon off;"
else
$@
fi
fi
5 changes: 4 additions & 1 deletion nginx/default.conf
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ server {
#! return 404;
#! }
#! proxy_pass ${REGISTRY_URL};
#! proxy_set_header Host ${HOST};
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is out of the scope and has been fixed with 1321d9b

## # Allow for authentication for access to backend registry
## proxy_set_header Authorization "Basic ${BASIC_AUTH}";
#! }

#error_page 404 /404.html;
Expand All @@ -42,4 +45,4 @@ server {
#location ~ /\.ht {
# deny all;
#}
}
}
2 changes: 1 addition & 1 deletion static.dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,4 @@ COPY --from=builder /usr/app/dist/ /usr/share/nginx/html/
COPY --from=builder /usr/app/dist/scripts/docker-registry-ui-static.js /usr/share/nginx/html/scripts/docker-registry-ui.js
COPY bin/entrypoint /bin

ENTRYPOINT entrypoint
ENTRYPOINT entrypoint