Procházet zdrojové kódy

fix: remove network segregation custom label

The tests for this feature are flaky, we don't know
yet if it's caused by the tests or the feature itself.
Nicolas Duchon před 2 týdny
rodič
revize
b0401d6184

+ 0 - 19
docs/README.md

@@ -1215,25 +1215,6 @@ docker run --detach \
 
 Network segregation make it possible to run the docker-gen container in an [internal network](https://docs.docker.com/reference/cli/docker/network/create/#internal), unreachable from the outside.
 
-You can also customise the label being used by docker-gen to find the nginx container with the `NGINX_CONTAINER_LABEL`environment variable (on the docker-gen container):
-
-```console
-docker run --detach \
-    --name docker-gen \
-    --volumes-from nginx \
-    --volume /var/run/docker.sock:/tmp/docker.sock:ro \
-    --volume $(pwd):/etc/docker-gen/templates \
-    --env "NGINX_CONTAINER_LABEL=com.github.foobarbuzz" \
-    nginxproxy/docker-gen -notify-sighup nginx -watch /etc/docker-gen/templates/nginx.tmpl /etc/nginx/conf.d/default.conf
-
-docker run --detach \
-    --name nginx \
-    --publish 80:80 \
-    --label "com.github.foobarbuzz" \
-    --volume "/tmp/nginx:/etc/nginx/conf.d" \
-    nginx
-```
-
 ⬆️ [back to table of contents](#table-of-contents)
 
 ## Docker Compose

+ 3 - 4
nginx.tmpl

@@ -13,7 +13,6 @@
 
 {{- $config := dict }}
 {{- $_ := set $config "nginx_proxy_version" $.Env.NGINX_PROXY_VERSION }}
-{{- $_ := set $config "nginx_container_label" ($.Env.NGINX_CONTAINER_LABEL | default "com.github.nginx-proxy.nginx-proxy.nginx") }}
 {{- $_ := set $config "default_cert_ok" (and (exists "/etc/nginx/certs/default.crt") (exists "/etc/nginx/certs/default.key")) }}
 {{- $_ := set $config "external_http_port" ($globals.Env.HTTP_PORT | default "80") }}
 {{- $_ := set $config "external_https_port" ($globals.Env.HTTPS_PORT | default "443") }}
@@ -47,9 +46,9 @@
 {{- $_ := set $globals "networks" (dict) }}
 
 {{- $currentContainer := where $globals.containers "ID" $globals.Docker.CurrentContainerID | first }}
-{{- $labeledContainer := whereLabelExists $globals.containers $globals.config.nginx_container_label | first }}
+{{- $labeledContainer := whereLabelExists $globals.containers "com.github.nginx-proxy.nginx-proxy.nginx" | first }}
 {{- $_ := set $globals "NetworkContainer" ($labeledContainer | default $currentContainer) }}
-# Networks available to the container labeled "{{ $globals.config.nginx_container_label }}" or the one running docker-gen
+# Networks available to the container labeled "com.github.nginx-proxy.nginx-proxy.nginx" or the one running docker-gen
 # (which are assumed to match the networks available to the container running nginx):
 {{- /*
      * Note:
@@ -64,7 +63,7 @@
 #     (none)
     {{- end }}
 {{- else }}
-# /!\ WARNING: Failed to find the Docker container labeled "{{ $globals.config.nginx_container_label }}" or the one running docker-gen. 
+# /!\ WARNING: Failed to find the Docker container labeled "com.github.nginx-proxy.nginx-proxy.nginx" or the one running docker-gen. 
 #              All upstream (backend) application containers will appear to be unreachable.
 #              Try removing the -only-exposed and -only-published arguments to docker-gen if you pass either of those. 
 #              See https://github.com/nginx-proxy/docker-gen/issues/458.

+ 0 - 45
test/test_dockergen/test_dockergen_network_segregation-custom-label.base.yml

@@ -1,45 +0,0 @@
-networks:
-  proxy:
-  private:
-    internal: true
-
-volumes:
-  nginx_conf:
-
-
-services:
-  nginx-proxy-nginx:
-    image: nginx
-    container_name: nginx
-    volumes:
-      - nginx_conf:/etc/nginx/conf.d:ro
-    ports:
-      - "80:80"
-      - "443:443"
-    networks:
-      - proxy
-    labels:
-      - "com.github.nginx-proxy.nginx-proxy.foobarbuzz"
-
-  nginx-proxy-dockergen:
-    image: nginxproxy/docker-gen
-    command: -notify-sighup nginx -watch /etc/docker-gen/templates/nginx.tmpl /etc/nginx/conf.d/default.conf
-    volumes:
-      - /var/run/docker.sock:/tmp/docker.sock:ro
-      - ../../nginx.tmpl:/etc/docker-gen/templates/nginx.tmpl
-      - nginx_conf:/etc/nginx/conf.d
-    environment:
-      NGINX_CONTAINER_LABEL: "com.github.nginx-proxy.nginx-proxy.foobarbuzz"
-    networks:
-      - private
-
-  web:
-    image: web
-    container_name: whoami2
-    expose:
-      - "80"
-    environment:
-      WEB_PORTS: "80"
-      VIRTUAL_HOST: whoami2.nginx.container.docker
-    networks:
-      - proxy

+ 0 - 27
test/test_dockergen/test_dockergen_network_segregation-custom-label.py

@@ -1,27 +0,0 @@
-import docker
-import pytest
-from packaging.version import Version
-
-
-raw_version = docker.from_env().version()["Version"]
-pytestmark = pytest.mark.skipif(
-    Version(raw_version) < Version("1.13"),
-    reason="Docker compose syntax v3 requires docker engine v1.13 or later (got {raw_version})"
-)
-
-
-def test_unknown_virtual_host_is_503(docker_compose, nginxproxy):
-    r = nginxproxy.get("http://unknown.nginx.container.docker/")
-    assert r.status_code == 503
-
-
-def test_forwards_to_whoami(docker_compose, nginxproxy):
-    r = nginxproxy.get("http://whoami2.nginx.container.docker/")
-    assert r.status_code == 200
-    whoami_container = docker_compose.containers.get("whoami2")
-    assert r.text == f"I'm {whoami_container.id[:12]}\n"
-
-
-if __name__ == "__main__":
-    import doctest
-    doctest.testmod()