Skip to content

Commit f064797

Browse files
committed
Added tests; Added healthcheck
1 parent 36d5203 commit f064797

File tree

6 files changed

+68
-0
lines changed

6 files changed

+68
-0
lines changed

.github/workflows/tests.yml

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
on: push
2+
name: Tests
3+
jobs:
4+
local-setup:
5+
runs-on: ubuntu-latest
6+
steps:
7+
- name: 'Checkout code'
8+
uses: actions/checkout@v4
9+
- name: 'Setup Docker'
10+
uses: docker-practice/actions-setup-docker@master
11+
- name: 'Debug versions'
12+
run: |
13+
docker --version
14+
- name: 'Add hosts to /etc/hosts'
15+
run: |
16+
sudo echo "127.0.0.1 reverse-proxy.test" | sudo tee -a /etc/hosts
17+
sudo echo "127.0.0.1 hello-world.test" | sudo tee -a /etc/hosts
18+
- name: 'Copy configuration files'
19+
run: cp -r configs-local configs
20+
- name: 'Start reverse proxy with local setup'
21+
run: docker compose -f docker-compose.local.yml up -d --wait
22+
- name: 'Test dashboard'
23+
run: curl http://reverse-proxy.test/dashboard/#/
24+
- name: 'Start hello-world example'
25+
run: cd examples && docker compose -f docker-compose.local.yml up -d
26+
- name: 'Test hello-world'
27+
run: curl http://hello-world.test

configs-local/traefik.yml

+5
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ entryPoints:
99
address: ":80"
1010
websecure:
1111
address: ":443"
12+
ping:
13+
address: ":8082"
1214

1315
# Access logs
1416
# accessLog: fields:
@@ -24,6 +26,9 @@ providers:
2426
directory: /etc/traefik/dynamic
2527
watch: true
2628

29+
ping:
30+
entryPoint: "ping"
31+
2732
api:
2833
dashboard: true
2934

configs-prod/traefik.yml

+5
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ entryPoints:
99
address: ":80"
1010
websecure:
1111
address: ":443"
12+
ping:
13+
address: ":8082"
1214

1315
# Access logs
1416
# accessLog: fields:
@@ -33,6 +35,9 @@ certificatesResolvers:
3335
3436
storage: /etc/traefik/acme/acme.json
3537

38+
ping:
39+
entryPoint: "ping"
40+
3641
api:
3742
dashboard: true
3843

docker-compose.local.yml

+6
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,12 @@ services:
1818
- ./certificates:/certs:ro
1919
- ./configs/traefik.yml:/etc/traefik/traefik.yml
2020
- ./configs/dynamic:/etc/traefik/dynamic
21+
healthcheck:
22+
test: ["CMD", "traefik", "healthcheck", "--ping"]
23+
interval: 5s
24+
timeout: 1s
25+
retries: 3
26+
start_period: 10s
2127
networks:
2228
routing:
2329
ipv4_address: 10.100.100.10

docker-compose.prod.yml

+6
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,11 @@ services:
1515
- ./configs/traefik.yml:/etc/traefik/traefik.yml
1616
- ./configs/dynamic:/etc/traefik/dynamic
1717
- ./certificates/acme.json:/etc/traefik/acme/acme.json
18+
healthcheck:
19+
test: [ "CMD", "traefik", "healthcheck", "--ping" ]
20+
interval: 5s
21+
timeout: 1s
22+
retries: 3
23+
start_period: 10s
1824
networks:
1925
- routing

examples/docker-compose.local.yml

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
version: '3.8'
2+
services:
3+
hello-world:
4+
image: nginx
5+
labels:
6+
- "traefik.enable=true"
7+
- "traefik.docker.network=reverse-proxy-docker-traefik_routing"
8+
- "traefik.http.routers.test.rule=Host(`hello-world.test`)"
9+
- "traefik.http.routers.test.entrypoints=web"
10+
- "traefik.http.services.test.loadbalancer.server.port=80"
11+
- "traefik.http.routers.test-https.rule=Host(`hello-world.test`)"
12+
- "traefik.http.routers.test-https.entrypoints=websecure"
13+
- "traefik.http.routers.test-https.tls=true"
14+
networks:
15+
- reverse-proxy
16+
networks:
17+
reverse-proxy:
18+
name: reverse-proxy-docker-traefik_routing
19+
external: true

0 commit comments

Comments
 (0)