Label configuration in docker for multiple services from the same docker compose file

Hi,
I'm running a docker swarm where I'd like to have Traefik as reverse proxy.

The services in the swarm are defined in docker-compose files.

I'll paste the files so they're easier to follow:

version: "3.3"

services:
  proxy:
    image: "traefik:v2.1"
    command:
      - "--api.insecure=true"
      - "--providers.docker=true"
      - "--entrypoints.web.address=:80"
      - "--providers.docker.swarmMode=true"
      - "--log.level=INFO"
    ports:
      - "80:80"
      - "8080:8080"
    volumes:
      - "/var/run/docker.sock:/var/run/docker.sock:ro"
    networks:
      #- default
      - traefik-public
    deploy:
      placement:
        constraints:
          - node.role == manager

networks:
  traefik-public:
    external: true

and then the whoami:

version: "3.3"

services:
  whoami:
    image: "containous/whoami"
    networks:
      - traefik-public
    deploy:
      labels:
        - "traefik.http.routers.whoami.rule=Host(`${HOST}`)"
        - "traefik.http.routers.whoami.entrypoints=web"
        - "traefik.http.services.whoami.loadbalancer.server.port=80"

networks:
  traefik-public:
    external: true

If i start this with:

docker stack deploy -c traefik.yml proxy
stack deploy -c whoami.yml one

It all works. But as soon as i run another instance of whoami it will of course override the configuration for whoami.

I can rename the service within the docker compose file to get it to work, but since I want to run about 100 of them behind Traefik i rather not edit it manually. And docker-compose doesn't support vars for service names within it's files. And renaming it would kind of be a bad idea anyway. (I want it to have the same name within each stack)

Is there any smart way to add the configuration for routing so it works from the stack name instead of the service name?

Any suggestions or smart tips would be appreciated.

If they are truly separate services. Then use an environment variable to replace whoami in the labels. I assume ${HOST} changes with each stack too?

It was possible to add '-' after the service name to separate them.
This solved the issue. Example where should be replaced:

traefik.http.routers-${COMPOSE_PROJECT_NAME}.tls.certresolver

That way i can reuse the docker-compose.yml file for each instance and simply set the COMPOSE_PROJECT_NAME env var.