Skip to content

Added label-based mechanism to identify docker-gen container. This is needed w… #205

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

Closed
wants to merge 4 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
14 changes: 14 additions & 0 deletions app/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,19 @@ function get_nginx_proxy_cid {
fi
}

function get_nginx_gen_cid {
# Check if any container has been labelled as the nginx gen container.
local labeled_cid=$(docker_api "/containers/json" | jq -r '.[] | select( .Labels["com.github.jrcs.letsencrypt_nginx_proxy_companion.nginx_gen"] == "true")|.Id')
if [[ ! -z "${labeled_cid:-}" ]]; then
export NGINX_DOCKER_GEN_CONTAINER=$labeled_cid
fi
if [[ -z "${NGINX_DOCKER_GEN_CONTAINER:-}" ]]; then
Copy link

Choose a reason for hiding this comment

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

Remove this condition to make it optional, don't error out. Document it instead.

echo "Error: can't get nginx-gen container id !" >&2
echo "Label the nginx gen container to use with 'com.github.jrcs.letsencrypt_nginx_proxy_companion.nginx_gen=true'." >&2
exit 1
fi
}

function check_writable_directory {
local dir="$1"
docker_api "/containers/$HOSTNAME/json" | jq ".Mounts[].Destination" | grep -q "^\"$dir\"$"
Expand Down Expand Up @@ -79,6 +92,7 @@ source /app/functions.sh

if [[ "$*" == "/bin/bash /app/start.sh" ]]; then
check_docker_socket
get_nginx_gen_cid
Copy link

Choose a reason for hiding this comment

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

I think this should be:

[[ -z "${NGINX_DOCKER_GEN_CONTAINER:-}" ]] && get_nginx_gen_cid

to allow still using a manual environment variable when you do have access to a static name.

if [[ -z "${NGINX_DOCKER_GEN_CONTAINER:-}" ]]; then
[[ -z "${NGINX_PROXY_CONTAINER:-}" ]] && get_nginx_proxy_cid
fi
Expand Down
3 changes: 2 additions & 1 deletion app/nginx_location.conf
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
location ^~ /.well-known/acme-challenge/ {
location ~ /.well-known {
Copy link

Choose a reason for hiding this comment

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

Out of scope, changes should be discarded.

# autoindex on;
allow all;
root /usr/share/nginx/html;
try_files $uri =404;
Expand Down