version: "3"

services:
  grav:
    container_name: grav
    image: lscr.io/linuxserver/grav:1.7.39.4-ls97
    ports:
      - ${APP_PORT}:80
    volumes:
      - ${APP_DATA_DIR}/data/grav-comfig:/config
    environment:
      - PUID=1000
      - PGID=1000
      - TZ=${TZ}
    networks:
      - tipi_main_network
    labels:
      # Main
      traefik.enable: true
      traefik.http.middlewares.grav-web-redirect.redirectscheme.scheme: https
      traefik.http.services.grav.loadbalancer.server.port: 80
      # Web
      traefik.http.routers.grav-insecure.rule: Host(`${APP_DOMAIN}`)
      traefik.http.routers.grav-insecure.entrypoints: web
      traefik.http.routers.grav-insecure.service: grav
      traefik.http.routers.grav-insecure.middlewares: grav-web-redirect
      # Websecure
      traefik.http.routers.grav.rule: Host(`${APP_DOMAIN}`)
      traefik.http.routers.grav.entrypoints: websecure
      traefik.http.routers.grav.service: grav
      traefik.http.routers.grav.tls.certresolver: myresolver
      # Local domain
      traefik.http.routers.grav-local-insecure.rule: Host(`grav.${LOCAL_DOMAIN}`)
      traefik.http.routers.grav-local-insecure.entrypoints: web
      traefik.http.routers.grav-local-insecure.service: grav
      traefik.http.routers.grav-local-insecure.middlewares: grav-web-redirect
      # Local domain secure
      traefik.http.routers.grav-local.rule: Host(`grav.${LOCAL_DOMAIN}`)
      traefik.http.routers.grav-local.entrypoints: websecure
      traefik.http.routers.grav-local.service: grav
      traefik.http.routers.grav-local.tls: true
