1 Running in Docker Swarm
James Mills edited this page 4 weeks ago

The following Docker Compose is used to run the twtxt.net pod in a Docker Swarm cluster behind a Traevik v2 Reverse Proxy using Let's Encrypt for TLS certificates:

---
version: "3.8"

services:
  twtxt:
    image: prologic/yarnd:latest
    command: -d /data -s bitcask:///data/twtxt.db
    environment:
      - BASE_URL=https://twtxt.net
      - OPEN_PROFILES=true
      - OPEN_REGISTRATIONS=true
      - DISABLE_GZIP=true
      - DISABLE_LOGGER=true
      - ADMIN_USER=prologic
      - ADMIN_NAME=James Mills
      - ADMIN_EMAIL=<redacted>
      - MAX_TWT_LENGTH=576
      - SMTP_HOST=mail.mills.io
      - SMTP_USER=noreply@twtxt.net
      - SMTP_FROM=noreply@twtxt.net
      - SMTP_PASS=<redacted>
      - API_SIGNING_KEY=<redacted>
      - COOKIE_SECRET=<redacted>
      - MAGICLINK_SECRET=<redacted>
    volumes:
      - twtxt:/data
    networks:
      - traefik
    extra_hosts:
      - "twtxt.net:<redacted>"
    deploy:
      mode: replicated
      replicas: 1
      placement:
        constraints:
          - "node.hostname == <redacted>"
      labels:
        - "xyz.megpoid.swarm-updater.enable=true"
        - "traefik.enable=true"
        - "traefik.docker.network=traefik"
        - "traefik.http.services.twtxt_twtxt.loadbalancer.server.port=8000"
        - "traefik.http.routers.twtxt_twtxt.rule=Host(`twtxt.net`)"
        - "traefik.http.routers.twtxt_twtxt.priority=2"
      resources:
        reservations:
          cpus: "2.0"
          memory: 1024M
        limits:
          cpus: "4.0"
          memory: 2048M
      restart_policy:
        condition: on-failure


networks:
  traefik:
    external: true

volumes:
  twtxt:
    driver: local