services:
  hedgedoc:
    # Make sure to use the latest release from https://hedgedoc.org/latest-release
    image: quay.io/hedgedoc/hedgedoc:1.10.3
    container_name: hedgedoc
    restart: unless-stopped
    environment:
      - CMD_DB_URL=postgres://${HEDGEDOC_DB_USER}:${HEDGEDOC_DB_PASSWORD}@${HEDGEDOC_DB_HOST}:${HEDGEDOC_DB_PORT}/${HEDGEDOC_DB_NAME}
      - CMD_DOMAIN=${HEDGEDOC_DOMAIN}
      - CMD_URL_ADDPORT=false
      - CMD_PROTOCOL_USESSL=true
      - CMD_ALLOW_EMAIL_REGISTER=false
      - CMD_HOST=0.0.0.0
      - CMD_PORT=3000
      - CMD_HSTS_ENABLE=true
    labels:
      - traefik.enable=true
      - traefik.docker.network=traefik
      - traefik.http.routers.hedgedoc.rule=Host(`${HEDGEDOC_DOMAIN}`)
      - traefik.http.routers.hedgedoc.entrypoints=web,websecure
      - traefik.http.routers.hedgedoc.middlewares=https-redirect
      - traefik.http.routers.hedgedoc.tls=true
      - traefik.http.routers.hedgedoc.tls.certresolver=le
      - traefik.http.routers.hedgedoc.service=hedgedoc
      - traefik.http.services.hedgedoc.loadbalancer.server.port=3000
      - traefik.http.middlewares.hedgedoc-websocket.headers.customrequestheaders.X-Forwarded-Proto=https
    volumes:
      - hedgedoc-uploads:/hedgedoc/public/uploads
    networks:
      - traefik
      - database

volumes:
  hedgedoc-uploads:
    name: hedgedoc-uploads

networks:
  traefik:
    name: traefik
    external: true
  database:
    name: database
    external: true
