I have tried to use traefik within github actions to run my containers everything works locally , but the routing does not work within Github actions. I don't know if this is github action issue, just asking here if anyone has some experience around it . I can share more details about my setup.
Hello @adesokanayo
This is a very interesting topic. Could you please share more details concerning your setup?
Thanks @jakubhajek . This routing works locally, I am showing some of the containers in the docker-compose
version: "3.4"
services:
serviceA:
container_name: serviceA
restart: 'always'
image: ${ECR_REGISTRY}/${ECR_SERVICEA_REPOSITORY}:${IMAGE_TAG}
env_file:
- .serviceA.env
expose:
- 8009
links:
- mysql
serviceB:
container_name: serviceB
restart: 'always'
image: ${ECR_REGISTRY}/${ECR_SERVICEB_REPOSITORY}:${IMAGE_TAG}
env_file:
- .serviceB.env
expose:
- 8002
links:
- mysql
labels:
- "traefik.enable=true"
- "traefik.http.routers.serviceB.rule=Host(`api.dev.localhost`)"
- "traefik.http.routers.serviceB.rule=PathPrefix(`/auth/myauth`)"
- "traefik.http.routers.serviceB.entrypoints=web"
serviceC:
container_name: serviceC
restart: 'always'
image: ${ECR_REGISTRY}/${ECR_SERVICEC_REPOSITORY}:${IMAGE_TAG}
env_file:
- .serviceC.env
ports:
- "8008:8008"
links:
- mysql
labels:
- "traefik.enable=true"
- "traefik.http.routers.serviceC.rule=Host(`api.dev.localhost`)"
- "traefik.http.routers.serviceC.rule=PathPrefix(`/route1`) || PathPrefix(`/route2`)"
- "traefik.http.routers.serviceC.entrypoints=web"
- "traefik.http.middlewares.myauth.forwardauth.address=http://api.dev.localhost/auth/myauth"
- "traefik.http.middlewares.myauth.forwardauth.trustForwardHeader=true"
- "traefik.http.middlewares.myauth.forwardauth.authResponseHeaders=Authorization, Set-Cookie"
- "traefik.http.routers.serviceC.middlewares=myauth@docker"
mainApp:
build:
dockerfile: ./Dockerfile
context: .
container_name: 'mainApp'
restart: 'always'
ports:
- "80:80"
- "443:443"
links:
- mysql
- serviceA
- serviceB
- serviceC
- traefik
volumes:
# Logs
- ./docker-temp/mainApp/apache/logs:/home/root/Sites/mainApp-apache-logs/
- ./docker-temp/mainApp/php/logs:/home/root/Sites/mainApp/tmp/logs/
labels:
- "traefik.enable=true"
- "traefik.http.routers.webserver.rule=!Host(`api.*`) || Host(`app.main.localhost`)"
- "traefik.http.routers.webserver.entrypoints=web"
mysql:
build:
context: ./bin/docker/mysql
dockerfile: Dockerfile
container_name: 'mysql'
restart: 'always'
ports:
- "3306:3306"
volumes:
- ./docker-temp/mysql/data:/var/lib/mysql
- ./docker-temp/mysql/log:/var/log/mysql
environment:
- MYSQL_ROOT_PASSWORD=someSensitivePassword
traefik:
image: "traefik:latest"
container_name: "traefik"
command:
#- "--log.level=DEBUG"
- "--api.insecure=true"
- "--accesslog=true"
- "--accesslog.format=json"
- "--providers.docker=true"
- "--providers.docker.exposedbydefault=false"
- "--entrypoints.web.address=:80"
- "--entrypoints.web.forwardedheaders.insecure=true"
ports:
- "80:80"
- "8080:8080"
volumes:
- "/var/run/docker.sock:/var/run/docker.sock:ro"
-
Traefik is expected to match the route app.main.localhost and send the request to my mainApp container . But that's not happening at all. I don't see any logs in the CI other than Traefik loading configurations.
-
Calls to api.dev.localhost/route1 and api.dev.localhost/route 2 should both be send to ServiceB for authentication .
-
Main App is also not displaying landing page when you send request to
http://app.main.localhost
1 , 2 and 3 works locally but not on the pipeline. Within the pipeline, all containers are created and able to running , including traefik, but the traefik returns 404 for the mainApp.
traefik | time="2022-06-14T13:39:29Z" level=info msg="Configuration loaded from flags."
Seems, that the root cause of the issue might be in the DNS name resolving. Can you please try to use names such as app.127.0.0.1.nip.io instead
of app.main.localhost
. I assume that once you deploy your stack via Github actions the name you configured can't be correctly resolved. I am not sure but it is worth trying suggestion.
Is there any new information on how we might setup traefik to work within Github Actions?
I have a working setup locally, but in my Github Actions I run into similar issues with op.
Context of my setup:
Using .NET Aspire to run web services on localhost:1234
Traefik config for localhost:1234 <-> myservice.com
Editing the host file within Github Actions to direct myservice.com to 127.0.0.1