version: '3.9'

services:
  app:
    image: gitea/gitea:{{gitea_version}}    
    environment:
      - USER_UID={{ service_user_id }}
      - USER_GID={{ service_group_id }}
      - GITEA__database__DB_TYPE=postgres
      - GITEA__database__HOST=db:5432
      - GITEA__database__NAME=${DB_NAME}
      - GITEA__database__USER=${DB_USER}
      - GITEA__database__PASSWD=${DB_PASSWORD}
      - ROOT_URL=https://git.lehmannhaus.de/
      - SSH_DOMAIN=git.lehmannhaus.de
    restart: always
    volumes:
      - {{ service_directory }}/data/appdata:/data
      - /etc/timezone:/etc/timezone:ro
      - /etc/localtime:/etc/localtime:ro
    ports:
      - '3000:3000'
      - '22:22'      
    networks:
      - default
  db:
    image: postgres:14    
    restart: always
    environment:
      - POSTGRES_USER=${DB_USER}
      - POSTGRES_PASSWORD=${DB_PASSWORD}
      - POSTGRES_DB=${DB_NAME}
    networks:
      - default 
    volumes:
      - {{ service_directory }}/data/db:/var/lib/postgresql/data

  runner:
    image: gitea/act_runner:latest
    restart: always
    environment:
      CONFIG_FILE: /config.yaml
      GITEA_INSTANCE_URL: "https://git.lehmannhaus.de"
      GITEA_RUNNER_REGISTRATION_TOKEN: "${RUNNER_REGISTRATION_TOKEN}"
      GITEA_RUNNER_NAME: "${RUNNER_NAME}"
      GITEA_RUNNER_LABELS: "nodejs-ubuntu:docker://node:latest,docker-ubuntu:docker://catthehacker/ubuntu:act-latest,docker-ubuntu-nonroot:docker://catthehacker/ubuntu:runner-latest"
    volumes:
      - /{{ service_directory }}/data/runner-config/config.yaml:/config.yaml
      - {{ service_directory }}/data/runner-data:/data
      - /var/run/docker.sock:/var/run/docker.sock

networks:
  default:
    ipam:
      driver: default
      config:
        - subnet: 172.2.0.0/16
          gateway: 172.2.0.1