services:
  server:
    image: codeberg.org/forgejo/forgejo:7
    container_name: forgejo
    environment:
      - USER_UID=1026
      - USER_GID=100
      - GITEA__database__DB_TYPE=sqlite3
      - TZ=Asia/Ho_Chi_Minh
      - GITEA__actions__ENABLED=true
      - INSTALL_LOCK=true
    restart: always
    networks:
      - forgejo_custom_net
    volumes:
      - ./data:/data
    ports:
      - "3050:3000"
      - "2222:22"

  runner:
    image: code.forgejo.org/forgejo/runner:6.0.1
    container_name: forgejo_runner
    restart: always
    user: "0:0"
    privileged: true
    depends_on:
      - server
    networks:
      - forgejo_custom_net
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
      - ./runner-data:/data
    entrypoint: 
      - sh
      - -c
      - |
        if [ ! -f /data/.runner ]; then
          forgejo-runner register --no-interactive \
            --instance http://server:3000 \
            --token Q0WgX6otU8NTnArZSJtZiz8zJmkl2S03Nu91DrXA \
            --name synology-runner \
            --labels ubuntu-latest:docker://node:20-bookworm,ubuntu-22.04:docker://node:20-bookworm,docker:host,docker:host
        fi
        forgejo-runner daemon
    environment:
      - TZ=Asia/Ho_Chi_Minh
      
networks:
  forgejo_custom_net:
    driver: bridge
    ipam:
      config:
        - subnet: 172.38.0.0/24
