services:
  gitea:
    image: ${GITEA_IMAGE:-docker.m.daocloud.io/gitea/gitea:1.22-rootless}
    pull_policy: if_not_present
    container_name: gitea
    restart: unless-stopped
    environment:
      GITEA__server__DOMAIN: localhost
      GITEA__server__ROOT_URL: http://localhost:3000/
      GITEA__server__SSH_DOMAIN: localhost
      GITEA__server__SSH_PORT: 2222
      GITEA__actions__ENABLED: "true"
      GITEA__actions__DEFAULT_ACTIONS_URL: "https://gitea.com/actions"
    ports:
      - "3000:3000"
      - "2222:2222"
    volumes:
      - gitea-data:/data

  gitea-job:
    build:
      context: .
      dockerfile: Dockerfile.gitea-job
      args:
        UBUNTU_IMAGE: ${UBUNTU_IMAGE:-docker.m.daocloud.io/ubuntu:24.04}
    image: ai-check-gitea-job:latest
    profiles: ["build"]

  gitea-runner:
    image: ${GITEA_RUNNER_IMAGE:-docker.m.daocloud.io/gitea/act_runner:0.2.11}
    pull_policy: if_not_present
    container_name: gitea-act-runner
    restart: unless-stopped
    depends_on:
      - gitea
    environment:
      CONFIG_FILE: /config.yaml
      GITEA_INSTANCE_URL: ${GITEA_INSTANCE_URL:-http://gitea:3000}
      GITEA_RUNNER_REGISTRATION_TOKEN: ${GITEA_RUNNER_REGISTRATION_TOKEN:-}
      GITEA_RUNNER_NAME: ${GITEA_RUNNER_NAME:-local-gitea-runner}
    volumes:
      - ./gitea-runner/config.yaml:/config.yaml:ro
      - gitea-runner-data:/data
      - /var/run/docker.sock:/var/run/docker.sock

volumes:
  gitea-data:
  gitea-runner-data:
