version: '3'

services:
  traefik:
    image: traefik
    ports:
      - "80:80"
      - "443:443"
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
      - ${PWD}/traefik.toml:/etc/traefik/traefik.toml
      - ${PWD}/traefik-dynamic.toml:/etc/traefik/traefik-dynamic.toml
      - ${PWD}/acme.json:/etc/traefik/acme.json
      - ${PWD}/access.log:/etc/traefik/access.log
      - ${PWD}/users:/etc/traefik/users

  goaccess:
    image: allinurl/goaccess
    command:
    - --no-global-config
    - --config-file=/srv/data/goaccess.conf
    - --num-tests=0
    volumes:
      - ${PWD}/access.log:/srv/logs/access.log:ro
      - ${PWD}/goaccess.conf:/srv/data/goaccess.conf
      - goaccess_data:/srv/data
      - goaccess_report:/srv/report
    labels:
      traefik.enable: true
      traefik.http.routers.goaccess.rule: Host(`gruppe1.testsites.info`) && PathPrefix(`/goaccess/ws`)
      traefik.http.routers.goaccess.priority: 55
      traefik.http.routers.goaccess.middlewares: strip_goaccess,goaccess_auth,secHeaders@file
      traefik.http.routers.goaccess.tls: true
      traefik.http.routers.goaccess.tls.certresolver: myresolver

  nginx:
    image: nginx
    volumes:
      - goaccess_report:/usr/share/nginx/html
    labels:
      traefik.enable: true
      traefik.http.routers.goaccess_web.rule: Host(`gruppe1.testsites.info`) && PathPrefix(`/goaccess`)
      traefik.http.routers.goaccess_web.priority: 50
      traefik.http.routers.goaccess_web.middlewares: strip_goaccess,goaccess_auth,secHeaders@file
      traefik.http.routers.goaccess_web.tls: true
      traefik.http.routers.goaccess_web.tls.certresolver: myresolver

      traefik.http.middlewares.strip_goaccess.stripprefix.prefixes: /goaccess
      traefik.http.middlewares.goaccess_auth.basicauth.usersfile: /etc/traefik/users

  portainer:
    image: portainer/portainer-ce
    labels:
      traefik.enable: true
      traefik.http.routers.portainer.rule: Host(`gruppe1.testsites.info`) && PathPrefix(`/portainer`)
      traefik.http.routers.portainer.priority: 50
      traefik.http.services.portainer.loadbalancer.server.port: 9000
      traefik.http.routers.portainer.middlewares: strip_portainer,secHeaders@file
      traefik.http.routers.portainer.tls: true
      traefik.http.routers.portainer.tls.certresolver: myresolver

      traefik.http.middlewares.strip_portainer.stripprefix.prefixes: /portainer
    volumes:
      - portainer_data:/data
      - /var/run/docker.sock:/var/run/docker.sock

  watchtower:
    image: containrrr/watchtower
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
      - /etc/localtime:/etc/localtime:ro
    env_file:
      - ${PWD}/.env

networks:
  default:
    external:
      name: net

volumes:
  portainer_data:
  goaccess_report:
  goaccess_data: