services:
  # Gitea
  gitea:
    image: gitea/gitea:latest-rootless
    container_name: gitea
    profiles:
      - gitea
    restart: on-failure:5
    depends_on:
      - database_gitea
      - caddy
    ports:
      - "22:22"
    env_file:
      - ./env/gitea.env
    volumes:
      - gitea_data:/var/lib/gitea
      - gitea_config:/etc/gitea
      - /etc/timezone:/etc/timezone:ro
      - /etc/localtime:/etc/localtime:ro
    networks:
      - infra-network
    security_opt:
      - no-new-privileges:true
  
  # Database gitea
  database_gitea:
    image: mariadb:latest
    container_name: database_gitea
    profiles:
      - gitea
    depends_on:
      - caddy
    restart: on-failure:5
    volumes:
      - gitea_db:/var/lib/mysql:rw
    env_file:
      - ./env/gitea_db.env
    command: '--default-authentication-plugin=mysql_native_password'
    networks:
      - infra-network
    security_opt:
      - no-new-privileges:true

  # Gitea-runner
  gitea-runner:
    image: gitea/act_runner:latest
    container_name: gitea-runner
    profiles:
      - gitea-runner
    depends_on:
      - gitea
    restart: on-failure:5
    env_file:
      - ./env/gitea-runner.env
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
      - gitea_runner:/data
      - ./config/gitea_runner/config.yaml:/config.yaml:ro
    networks:
      - infra-network
    security_opt:
      - no-new-privileges:true

volumes:
  gitea_data:
    name: gitea_data
  gitea_config:
    name: gitea_config
  gitea_db:
    name: gitea_db
  gitea_runner:
    name: gitea_runner
