From 75089e4bacaa08e68427bb466ea34a95a1ab6cb6 Mon Sep 17 00:00:00 2001 From: korridor <26689068+korridor@users.noreply.github.com> Date: Wed, 6 Mar 2024 11:31:03 +0100 Subject: [PATCH 1/2] Upgraded to 2.11.0 --- docker-compose.local.yml | 2 +- docker-compose.prod.yml | 2 +- license.md | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/docker-compose.local.yml b/docker-compose.local.yml index 44b71c6..9bea951 100644 --- a/docker-compose.local.yml +++ b/docker-compose.local.yml @@ -7,7 +7,7 @@ networks: - subnet: 10.100.100.0/24 services: traefik: - image: traefik:2.9.1 + image: traefik:2.11.0 restart: always container_name: reverse_proxy_traefik ports: diff --git a/docker-compose.prod.yml b/docker-compose.prod.yml index bb9faf9..780dbd6 100644 --- a/docker-compose.prod.yml +++ b/docker-compose.prod.yml @@ -4,7 +4,7 @@ networks: driver: bridge services: traefik: - image: traefik:2.9.1 + image: traefik:2.11.0 restart: always container_name: reverse_proxy_traefik ports: diff --git a/license.md b/license.md index 6734192..4098013 100644 --- a/license.md +++ b/license.md @@ -1,7 +1,7 @@ The MIT License (MIT) ===================== -Copyright © `2020` `korridor` +Copyright © `2024` `korridor` Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation From 9c0b1f10a8169e68580b809376ad45ef68e9f119 Mon Sep 17 00:00:00 2001 From: korridor <26689068+korridor@users.noreply.github.com> Date: Wed, 6 Mar 2024 11:31:10 +0100 Subject: [PATCH 2/2] Added tests; Added healthcheck --- .github/workflows/tests.yml | 27 +++++++++++++++++++++++++++ configs-local/traefik.yml | 5 +++++ configs-prod/traefik.yml | 5 +++++ docker-compose.local.yml | 6 ++++++ docker-compose.prod.yml | 6 ++++++ examples/docker-compose.local.yml | 19 +++++++++++++++++++ 6 files changed, 68 insertions(+) create mode 100644 .github/workflows/tests.yml create mode 100644 examples/docker-compose.local.yml diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml new file mode 100644 index 0000000..f88e2da --- /dev/null +++ b/.github/workflows/tests.yml @@ -0,0 +1,27 @@ +on: push +name: Tests +jobs: + local-setup: + runs-on: ubuntu-latest + steps: + - name: 'Checkout code' + uses: actions/checkout@v4 + - name: 'Setup Docker' + uses: docker-practice/actions-setup-docker@master + - name: 'Debug versions' + run: | + docker --version + - name: 'Add hosts to /etc/hosts' + run: | + sudo echo "127.0.0.1 reverse-proxy.test" | sudo tee -a /etc/hosts + sudo echo "127.0.0.1 hello-world.test" | sudo tee -a /etc/hosts + - name: 'Copy configuration files' + run: cp -r configs-local configs + - name: 'Start reverse proxy with local setup' + run: docker compose -f docker-compose.local.yml up -d --wait + - name: 'Test dashboard' + run: curl http://reverse-proxy.test/dashboard/#/ + - name: 'Start hello-world example' + run: cd examples && docker compose -f docker-compose.local.yml up -d + - name: 'Test hello-world' + run: curl http://hello-world.test diff --git a/configs-local/traefik.yml b/configs-local/traefik.yml index 9f9cfa7..31b796b 100644 --- a/configs-local/traefik.yml +++ b/configs-local/traefik.yml @@ -9,6 +9,8 @@ entryPoints: address: ":80" websecure: address: ":443" + ping: + address: ":8082" # Access logs # accessLog: fields: @@ -24,6 +26,9 @@ providers: directory: /etc/traefik/dynamic watch: true +ping: + entryPoint: "ping" + api: dashboard: true diff --git a/configs-prod/traefik.yml b/configs-prod/traefik.yml index 72c2205..9f21d05 100644 --- a/configs-prod/traefik.yml +++ b/configs-prod/traefik.yml @@ -9,6 +9,8 @@ entryPoints: address: ":80" websecure: address: ":443" + ping: + address: ":8082" # Access logs # accessLog: fields: @@ -33,6 +35,9 @@ certificatesResolvers: email: mail@somedomain.com storage: /etc/traefik/acme/acme.json +ping: + entryPoint: "ping" + api: dashboard: true diff --git a/docker-compose.local.yml b/docker-compose.local.yml index 9bea951..e6a20b7 100644 --- a/docker-compose.local.yml +++ b/docker-compose.local.yml @@ -18,6 +18,12 @@ services: - ./certificates:/certs:ro - ./configs/traefik.yml:/etc/traefik/traefik.yml - ./configs/dynamic:/etc/traefik/dynamic + healthcheck: + test: ["CMD", "traefik", "healthcheck", "--ping"] + interval: 5s + timeout: 1s + retries: 3 + start_period: 10s networks: routing: ipv4_address: 10.100.100.10 diff --git a/docker-compose.prod.yml b/docker-compose.prod.yml index 780dbd6..0f0d246 100644 --- a/docker-compose.prod.yml +++ b/docker-compose.prod.yml @@ -15,5 +15,11 @@ services: - ./configs/traefik.yml:/etc/traefik/traefik.yml - ./configs/dynamic:/etc/traefik/dynamic - ./certificates/acme.json:/etc/traefik/acme/acme.json + healthcheck: + test: [ "CMD", "traefik", "healthcheck", "--ping" ] + interval: 5s + timeout: 1s + retries: 3 + start_period: 10s networks: - routing diff --git a/examples/docker-compose.local.yml b/examples/docker-compose.local.yml new file mode 100644 index 0000000..57bd67c --- /dev/null +++ b/examples/docker-compose.local.yml @@ -0,0 +1,19 @@ +version: '3.8' +services: + hello-world: + image: nginx + labels: + - "traefik.enable=true" + - "traefik.docker.network=reverse-proxy-docker-traefik_routing" + - "traefik.http.routers.test.rule=Host(`hello-world.test`)" + - "traefik.http.routers.test.entrypoints=web" + - "traefik.http.services.test.loadbalancer.server.port=80" + - "traefik.http.routers.test-https.rule=Host(`hello-world.test`)" + - "traefik.http.routers.test-https.entrypoints=websecure" + - "traefik.http.routers.test-https.tls=true" + networks: + - reverse-proxy +networks: + reverse-proxy: + name: reverse-proxy-docker-traefik_routing + external: true