Skip to content

Commit 1fc38f8

Browse files
authored
refactor: move to correctly namespaced labels (#1046)
1 parent ca1f5a4 commit 1fc38f8

File tree

13 files changed

+281
-22
lines changed

13 files changed

+281
-22
lines changed

.github/workflows/test.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ jobs:
8383
test-name:
8484
[
8585
docker_api,
86+
docker_api_legacy,
8687
location_config,
8788
certs_single,
8889
certs_san,

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1+
.docker
2+
.vscode
13
certs/
24
conf.d/
35
data/
46
vhost.d/
5-
.vscode
67

78
# tests
89
go/

app/entrypoint.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,13 +157,13 @@ if [[ "$*" == "/bin/bash /app/start.sh" ]]; then
157157
echo "Check that you are doing one of the following :" >&2
158158
echo -e "\t- Use the --volumes-from option to mount volumes from the nginx-proxy container." >&2
159159
echo -e "\t- Set the NGINX_PROXY_CONTAINER env var on the letsencrypt-companion container to the name of the nginx-proxy container." >&2
160-
echo -e "\t- Label the nginx-proxy container to use with 'com.github.jrcs.letsencrypt_nginx_proxy_companion.nginx_proxy'." >&2
160+
echo -e "\t- Label the nginx-proxy container to use with 'com.github.nginx-proxy.nginx'." >&2
161161
exit 1
162162
elif [[ -z "$(get_docker_gen_container)" ]] && ! is_docker_gen_container "$(get_nginx_proxy_container)"; then
163163
echo "Error: can't get docker-gen container id !" >&2
164164
echo "If you are running a three containers setup, check that you are doing one of the following :" >&2
165165
echo -e "\t- Set the NGINX_DOCKER_GEN_CONTAINER env var on the letsencrypt-companion container to the name of the docker-gen container." >&2
166-
echo -e "\t- Label the docker-gen container to use with 'com.github.jrcs.letsencrypt_nginx_proxy_companion.docker_gen'." >&2
166+
echo -e "\t- Label the docker-gen container to use with 'com.github.nginx-proxy.docker-gen'." >&2
167167
exit 1
168168
fi
169169
check_writable_directory '/etc/nginx/certs'

app/functions.sh

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,9 @@ function is_docker_gen_container {
278278

279279
function get_docker_gen_container {
280280
# First try to get the docker-gen container ID from the container label.
281-
local docker_gen_cid; docker_gen_cid="$(labeled_cid com.github.jrcs.letsencrypt_nginx_proxy_companion.docker_gen)"
281+
local legacy_docker_gen_cid; legacy_docker_gen_cid="$(labeled_cid com.github.jrcs.letsencrypt_nginx_proxy_companion.docker_gen)"
282+
local new_docker_gen_cid; new_docker_gen_cid="$(labeled_cid com.github.nginx-proxy.docker-gen)"
283+
local docker_gen_cid; docker_gen_cid="${new_docker_gen_cid:-$legacy_docker_gen_cid}"
282284

283285
# If the labeled_cid function dit not return anything and the env var is set, use it.
284286
if [[ -z "$docker_gen_cid" ]] && [[ -n "${NGINX_DOCKER_GEN_CONTAINER:-}" ]]; then
@@ -292,7 +294,9 @@ function get_docker_gen_container {
292294
function get_nginx_proxy_container {
293295
local volumes_from
294296
# First try to get the nginx container ID from the container label.
295-
local nginx_cid; nginx_cid="$(labeled_cid com.github.jrcs.letsencrypt_nginx_proxy_companion.nginx_proxy)"
297+
local legacy_nginx_cid; legacy_nginx_cid="$(labeled_cid com.github.jrcs.letsencrypt_nginx_proxy_companion.nginx_proxy)"
298+
local new_nginx_cid; new_nginx_cid="$(labeled_cid com.github.nginx-proxy.nginx)"
299+
local nginx_cid; nginx_cid="${new_nginx_cid:-$legacy_nginx_cid}"
296300

297301
# If the labeled_cid function dit not return anything ...
298302
if [[ -z "${nginx_cid}" ]]; then

docs/Advanced-usage.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ Please read and try [basic usage](./Basic-usage.md), and **validate that you hav
1010
curl https://raw.githubusercontent.com/nginx-proxy/nginx-proxy/main/nginx.tmpl > /path/to/nginx.tmpl
1111
```
1212

13-
2) Use the `com.github.jrcs.letsencrypt_nginx_proxy_companion.docker_gen` label on the **docker-gen** container, or explicitly set the `NGINX_DOCKER_GEN_CONTAINER` environment variable on the **acme-companion** container to the name or id of the **docker-gen** container (we'll use the later method in the example).
13+
2) Use the `com.github.nginx-proxy.docker-gen` label on the **docker-gen** container, or explicitly set the `NGINX_DOCKER_GEN_CONTAINER` environment variable on the **acme-companion** container to the name or id of the **docker-gen** container (we'll use the later method in the example).
1414

1515
3) Declare `/etc/nginx/conf.d` as a volume on the nginx container so that it can be shared with the **docker-gen** container.
1616

docs/Docker-Compose.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ services:
8282
- /path/to/nginx.tmpl:/etc/docker-gen/templates/nginx.tmpl:ro
8383
- /var/run/docker.sock:/tmp/docker.sock:ro
8484
labels:
85-
- "com.github.jrcs.letsencrypt_nginx_proxy_companion.docker_gen"
85+
- "com.github.nginx-proxy.docker-gen"
8686
network_mode: bridge
8787

8888
acme-companion:

docs/Getting-containers-IDs.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@ For **acme-companion** to work properly, it needs to know the ID of the **nginx*
44

55
There are three methods to inform the **acme-companion** container of the **nginx**/**nginx-proxy** container ID:
66

7-
* `label` method: add the label `com.github.jrcs.letsencrypt_nginx_proxy_companion.nginx_proxy` to the **nginx**/**nginx-proxy** container.
7+
* `label` method: add the label `com.github.nginx-proxy.nginx` to the **nginx**/**nginx-proxy** container.
88

99
* `environment variable` method: assign a fixed name to the **nginx**/**nginx-proxy** container with `container_name:` and set the environment variable `NGINX_PROXY_CONTAINER` to this name on the **acme-companion** container.
1010

1111
* `volumes_from` method. Using this method, the **acme-companion** container will get the **nginx**/**nginx-proxy** container ID from the volumes it got using the `volumes_from` option.
1212

1313
And two methods to inform the **acme-companion** container of the **docker-gen** container ID:
1414

15-
* `label` method: add the label `com.github.jrcs.letsencrypt_nginx_proxy_companion.docker_gen` to the **docker-gen** container.
15+
* `label` method: add the label `com.github.nginx-proxy.docker-gen` to the **docker-gen** container.
1616

1717
* `environment variable` method: assign a fixed name to the **docker-gen** container with `container_name:` and set the environment variable `NGINX_DOCKER_GEN_CONTAINER` to this name on the **acme-companion** container.
1818

@@ -26,12 +26,12 @@ The advantage the `label` methods have over the `environment variable` (and `vol
2626
```
2727
$ docker run --detach \
2828
[...]
29-
--label com.github.jrcs.letsencrypt_nginx_proxy_companion.nginx_proxy \
29+
--label com.github.nginx-proxy.nginx \
3030
nginx
3131
3232
$ docker run --detach \
3333
[...]
34-
--label com.github.jrcs.letsencrypt_nginx_proxy_companion.docker_gen \
34+
--label com.github.nginx-proxy.docker-gen \
3535
nginxproxy/docker-gen
3636
3737
$ docker run --detach \
@@ -67,7 +67,7 @@ $ docker run --detach \
6767
6868
$ docker run --detach \
6969
[...]
70-
--label com.github.jrcs.letsencrypt_nginx_proxy_companion.docker_gen \
70+
--label com.github.nginx-proxy.docker-gen \
7171
nginxproxy/docker-gen
7272
7373
$ docker run --detach \

test/config.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ set -e
33

44
globalTests+=(
55
docker_api
6+
docker_api_legacy
67
location_config
78
default_cert
89
certs_single

test/setup/setup-local.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ EOF
130130
get_environment
131131

132132
# Stop and remove nginx-proxy and (if required) docker-gen
133-
for cid in $(docker ps -a --filter "label=com.github.jrcs.letsencrypt_nginx_proxy_companion.test_suite" --format "{{.ID}}"); do
133+
for cid in $(docker ps -a --filter "label=com.github.nginx-proxy.acme-companion.test-suite" --format "{{.ID}}"); do
134134
docker stop "$cid"
135135
docker rm --volumes "$cid"
136136
done

test/setup/setup-nginx-proxy.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ case $SETUP in
2828
-v /etc/nginx/vhost.d \
2929
-v /usr/share/nginx/html \
3030
-v /var/run/docker.sock:/tmp/docker.sock:ro \
31-
--label com.github.jrcs.letsencrypt_nginx_proxy_companion.test_suite \
31+
--label com.github.nginx-proxy.acme-companion.test-suite \
3232
--network "$test_net" \
3333
nginxproxy/nginx-proxy
3434
;;
@@ -42,7 +42,7 @@ case $SETUP in
4242
-v /etc/nginx/conf.d \
4343
-v /etc/nginx/vhost.d \
4444
-v /usr/share/nginx/html \
45-
--label com.github.jrcs.letsencrypt_nginx_proxy_companion.test_suite \
45+
--label com.github.nginx-proxy.acme-companion.test-suite \
4646
--network "$test_net" \
4747
nginx:alpine
4848

@@ -51,7 +51,7 @@ case $SETUP in
5151
--volumes-from "$NGINX_CONTAINER_NAME" \
5252
-v "${GITHUB_WORKSPACE}/nginx.tmpl:/etc/docker-gen/templates/nginx.tmpl:ro" \
5353
-v /var/run/docker.sock:/tmp/docker.sock:ro \
54-
--label com.github.jrcs.letsencrypt_nginx_proxy_companion.test_suite \
54+
--label com.github.nginx-proxy.acme-companion.test-suite \
5555
--network "$test_net" \
5656
nginxproxy/docker-gen \
5757
-notify-sighup "$NGINX_CONTAINER_NAME" -watch /etc/docker-gen/templates/nginx.tmpl /etc/nginx/conf.d/default.conf

0 commit comments

Comments
 (0)