services:
  docuseal:
    image: docuseal/docuseal:latest
    container_name: docuseal
    depends_on:
      docuseal-db:
        condition: service_healthy
    volumes:
      - docuseal_data:/data/docuseal
    environment:
      - DATABASE_URL=postgresql://docuseal:docuseal_secret@docuseal-db:5432/docuseal
      - SMTP_ADDRESS=in-v3.mailjet.com
      - SMTP_PORT=587
      - SMTP_USERNAME=e9046434df02d6f63a9c2c6e430355cb
      - SMTP_PASSWORD=422ba5fe5cb9571df62c73e5edf9a3e1
      - SMTP_DOMAIN=targo.ca
      - SMTP_FROM=Gigafibre <noreply@targo.ca>
      - SMTP_AUTHENTICATION=plain
      - SMTP_ENABLE_STARTTLS=true
    restart: unless-stopped
    networks:
      - proxy
      - default
    labels:
      - "traefik.enable=true"
      - "traefik.docker.network=proxy"
      - "traefik.http.routers.docuseal.rule=Host(`sign.gigafibre.ca`)"
      - "traefik.http.routers.docuseal.entrypoints=websecure"
      - "traefik.http.routers.docuseal.tls.certresolver=letsencrypt"
      - "traefik.http.services.docuseal.loadbalancer.server.port=3000"

  docuseal-db:
    image: postgres:16-alpine
    container_name: docuseal-db
    volumes:
      - docuseal_pg:/var/lib/postgresql/data
    environment:
      POSTGRES_USER: docuseal
      POSTGRES_PASSWORD: docuseal_secret
      POSTGRES_DB: docuseal
    healthcheck:
      test: ["CMD-SHELL", "pg_isready -U docuseal"]
      interval: 5s
      timeout: 5s
      retries: 5
    restart: unless-stopped

volumes:
  docuseal_data:
  docuseal_pg:

networks:
  proxy:
    external: true
