version: '3.9'

services:
  gitea:
    image: gitea/gitea:1.21.11
    environment:
      - GITEA__database__DB_TYPE=mysql
      - GITEA__database__HOST=mariadb_mariadb_primary:3306
      - GITEA__database__NAME=gitea
      - GITEA__database__USER=gitea
      - GITEA__database__PASSWD__FILE=/run/secrets/gitea_db_password
      - GITEA__server__ROOT_URL=https://gitea.pressmess.duckdns.org/
      - GITEA__server__SSH_DOMAIN=gitea.pressmess.duckdns.org
      - GITEA__server__SSH_PORT=2222
      - GITEA__service__DISABLE_REGISTRATION=true
    secrets:
      - gitea_db_password
    volumes:
      - /export/gitea:/data
    networks:
      - caddy-public
      - database-network
    ports:
      - target: 22
        published: 2222
        mode: host
    deploy:
      placement:
        constraints:
          - "node.labels.role==db"
      replicas: 1

secrets:
  gitea_db_password:
    external: true

networks:
  caddy-public:
    external: true
  database-network:
    external: true
