version: "3.7"
services:
  stalwart-mail:
    image: stalwartlabs/mail-server:v0.7.3
    container_name: stalwart-mail
    volumes:
      - ${APP_DATA_DIR}/data:/opt/stalwart-mail
    restart: unless-stopped
    networks:
      - tipi_main_network
    ports:
      - ${NETWORK_INTERFACE:-0.0.0.0}:25:25/tcp
      - ${NETWORK_INTERFACE:-0.0.0.0}:143:143/tcp
      - ${NETWORK_INTERFACE:-0.0.0.0}:465:465/tcp
      - ${NETWORK_INTERFACE:-0.0.0.0}:587:587/tcp
      - ${NETWORK_INTERFACE:-0.0.0.0}:993:993/tcp
      - ${NETWORK_INTERFACE:-0.0.0.0}:4190:4190/tcp
      - ${APP_PORT}:8080
    labels:
      # Main
      traefik.enable: true
      traefik.http.middlewares.stalwart-mail-web-redirect.redirectscheme.scheme: https
      traefik.http.services.stalwart-mail.loadbalancer.server.port: 8080
      # Web
      traefik.http.routers.stalwart-mail-insecure.rule: Host(`${APP_DOMAIN}`)
      traefik.http.routers.stalwart-mail-insecure.entrypoints: web
      traefik.http.routers.stalwart-mail-insecure.service: stalwart-mail
      traefik.http.routers.stalwart-mail-insecure.middlewares: stalwart-mail-web-redirect
      # Websecure
      traefik.http.routers.stalwart-mail.rule: Host(`${APP_DOMAIN}`)
      traefik.http.routers.stalwart-mail.entrypoints: websecure
      traefik.http.routers.stalwart-mail.service: stalwart-mail
      traefik.http.routers.stalwart-mail.tls.certresolver: myresolver
      # Local domain
      traefik.http.routers.stalwart-mail-local-insecure.rule: Host(`stalwart-mail.${LOCAL_DOMAIN}`)
      traefik.http.routers.stalwart-mail-local-insecure.entrypoints: web
      traefik.http.routers.stalwart-mail-local-insecure.service: stalwart-mail
      traefik.http.routers.stalwart-mail-local-insecure.middlewares: stalwart-mail-web-redirect
      # Local domain secure
      traefik.http.routers.stalwart-mail-local.rule: Host(`stalwart-mail.${LOCAL_DOMAIN}`)
      traefik.http.routers.stalwart-mail-local.entrypoints: websecure
      traefik.http.routers.stalwart-mail-local.service: stalwart-mail
      traefik.http.routers.stalwart-mail-local.tls: true
