Skip to content

Commit

Permalink
Added tests; Added healthcheck
Browse files Browse the repository at this point in the history
  • Loading branch information
korridor committed Mar 6, 2024
1 parent 75089e4 commit 74ba7d1
Show file tree
Hide file tree
Showing 6 changed files with 65 additions and 0 deletions.
24 changes: 24 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
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: '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
5 changes: 5 additions & 0 deletions configs-local/traefik.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ entryPoints:
address: ":80"
websecure:
address: ":443"
ping:
address: ":8082"

# Access logs
# accessLog: fields:
Expand All @@ -24,6 +26,9 @@ providers:
directory: /etc/traefik/dynamic
watch: true

ping:
entryPoint: "ping"

api:
dashboard: true

Expand Down
5 changes: 5 additions & 0 deletions configs-prod/traefik.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ entryPoints:
address: ":80"
websecure:
address: ":443"
ping:
address: ":8082"

# Access logs
# accessLog: fields:
Expand All @@ -33,6 +35,9 @@ certificatesResolvers:
email: [email protected]
storage: /etc/traefik/acme/acme.json

ping:
entryPoint: "ping"

api:
dashboard: true

Expand Down
6 changes: 6 additions & 0 deletions docker-compose.local.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
6 changes: 6 additions & 0 deletions docker-compose.prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
19 changes: 19 additions & 0 deletions examples/docker-compose.local.yml
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 74ba7d1

Please sign in to comment.