version: "3.3"

services:
  traefik:
    image: "traefik:v2.11"
    restart: unless-stopped
    container_name: "proxy"
    command:
      - "--log.level=DEBUG"
      - "--providers.docker=true"
      - "--providers.docker.exposedbydefault=false"
      - "--entrypoints.web.address=:8082"
    ports:
      - "8082:8082"
    volumes:
      - "/var/run/docker.sock:/var/run/docker.sock:ro"

  home:
    image: "jo2024/home"
    restart: unless-stopped
    container_name: "home-service"
    build:
        context: .
        dockerfile: ./home/Dockerfile
    labels:
      - "traefik.enable=true"
      - "traefik.http.routers.home-service.entrypoints=web"
      - "traefik.http.routers.home.rule=PathPrefix(`/`)"
      - "traefik.http.routers.home.middlewares=home-stripprefix"
      - "traefik.http.middlewares.home-stripprefix.stripprefix.prefixes=/"
      - "traefik.http.routers.home-service.priority=1"
      - "traefik.http.routers.home-service.service=home-service"
      - "traefik.http.services.home-service.loadbalancer.server.port=80"
      - "traefik.http.services.home-service.loadbalancer.server.scheme=http"
      - "traefik.http.services.home-service.loadbalancer.passhostheader=true"

  athlete:
    image: "jo2024/athlete"
    restart: unless-stopped
    container_name: "athlete-service"
    build:
        context: .
        dockerfile: ./athlete/Dockerfile
    labels:
      - "traefik.enable=true"
      - "traefik.http.routers.athletes-service.entrypoints=web"
      - "traefik.http.routers.athletes.rule=PathPrefix(`/athletes{regex:$$|/.*}`) || PathPrefix(`/swagger{regex:$$|/.*}`)"
      - "traefik.http.routers.athletes.middlewares=athletes-stripprefix"
      - "traefik.http.middlewares.athletes-stripprefix.stripprefix.prefixes=/athletes"
    volumes:
      - "athlete:/app/data"

  discipline:
    image: "jo2024/discipline"
    restart: unless-stopped
    container_name: "discipline-service"
    build:
        context: .
        dockerfile: ./discipline/Dockerfile
    labels:
      - "traefik.enable=true"
      - "traefik.http.routers.disciplines-service.entrypoints=web"
      - "traefik.http.routers.disciplines.rule=PathPrefix(`/disciplines{regex:$$|/.*}`)"
      - "traefik.http.routers.disciplines.middlewares=disciplines-stripprefix"
      - "traefik.http.middlewares.disciplines-stripprefix.stripprefix.prefixes=/disciplines"
    volumes:
      - "discipline:/app/data"

  medaille:
    image: "jo2024/medaille"
    restart: unless-stopped
    container_name: "medaille-service"
    build:
        context: .
        dockerfile: ./medaille/Dockerfile
    labels:
      - "traefik.enable=true"
      - "traefik.http.routers.medaille-service.entrypoints=web"
      - "traefik.http.routers.medaille.rule=PathPrefix(`/medailles{regex:$$|/.*}`)"
      - "traefik.http.routers.medaille.middlewares=medaille-stripprefix"
      - "traefik.http.middlewares.medaille-stripprefix.stripprefix.prefixes=/medailles"
    volumes:
      - "medaille:/app/data"

volumes:
    athlete:
    discipline:
    medaille: