version: "3.8"
services:
  mongo:
    container_name: mongo
    image: mongo:7.0.2
    restart: unless-stopped
    ports:
      - ${APP_PORT}:27017
    networks:
      - tipi_main_network
    environment:
      - MONGO_INITDB_ROOT_USERNAME=${MONGO_INITDB_ROOT_USERNAME}
      - MONGO_INITDB_ROOT_PASSWORD=${MONGO_INITDB_ROOT_PASSWORD}
    labels:
      # Main
      traefik.enable: true
      traefik.http.middlewares.mongo-web-redirect.redirectscheme.scheme: https
      traefik.http.services.mongo.loadbalancer.server.port: 27017
      # Web
      traefik.http.routers.mongo-insecure.rule: Host(`${APP_DOMAIN}`)
      traefik.http.routers.mongo-insecure.entrypoints: web
      traefik.http.routers.mongo-insecure.service: mongo
      traefik.http.routers.mongo-insecure.middlewares: mongo-web-redirect
      # Websecure
      traefik.http.routers.mongo.rule: Host(`${APP_DOMAIN}`)
      traefik.http.routers.mongo.entrypoints: websecure
      traefik.http.routers.mongo.service: mongo
      traefik.http.routers.mongo.tls.certresolver: myresolver
      # Local domain
      traefik.http.routers.mongo-local-insecure.rule: Host(`mongo.${LOCAL_DOMAIN}`)
      traefik.http.routers.mongo-local-insecure.entrypoints: web
      traefik.http.routers.mongo-local-insecure.service: mongo
      traefik.http.routers.mongo-local-insecure.middlewares: mongo-web-redirect
      # Local domain secure
      traefik.http.routers.mongo-local.rule: Host(`mongo.${LOCAL_DOMAIN}`)
      traefik.http.routers.mongo-local.entrypoints: websecure
      traefik.http.routers.mongo-local.service: mongo
      traefik.http.routers.mongo-local.tls: true
