# koopa-forgejo — ROOTLESS Forgejo image + rootless podman (user hernani)
# Site: https://git.hacktivism.ch  |  HTTP :9024  |  SSH :9200
services:
  forgejo:
    image: codeberg.org/forgejo/forgejo:11-rootless
    container_name: koopa-forgejo
    restart: unless-stopped
    user: "1000:1000"
    userns_mode: keep-id
    env_file: [.env]
    environment:
      USER_UID: "1000"
      USER_GID: "1000"
      FORGEJO__database__DB_TYPE: postgres
      FORGEJO__database__HOST: db:5432
      FORGEJO__database__NAME: forgejo
      FORGEJO__database__USER: forgejo
      FORGEJO__database__PASSWD: ${FORGEJO_DB_PASSWORD}
      FORGEJO__server__DOMAIN: git.hacktivism.ch
      FORGEJO__server__SSH_DOMAIN: git.hacktivism.ch
      FORGEJO__server__ROOT_URL: https://git.hacktivism.ch/
      FORGEJO__server__HTTP_PORT: "3000"
      FORGEJO__server__SSH_PORT: "9200"
      FORGEJO__server__SSH_LISTEN_PORT: "2222"
      FORGEJO__server__START_SSH_SERVER: "true"
      FORGEJO__server__DISABLE_SSH: "false"
      FORGEJO__server__LANDING_PAGE: explore
      FORGEJO__service__DISABLE_REGISTRATION: "true"
      FORGEJO__service__ALLOW_ONLY_EXTERNAL_REGISTRATION: "false"
      FORGEJO__service__SHOW_REGISTRATION_BUTTON: "false"
      FORGEJO__service__REQUIRE_SIGNIN_VIEW: "false"
      FORGEJO__service__DEFAULT_ALLOW_CREATE_ORGANIZATION: "true"
      FORGEJO__openid__ENABLE_OPENID_SIGNIN: "false"
      FORGEJO__openid__ENABLE_OPENID_SIGNUP: "false"
      FORGEJO__repository__DEFAULT_PRIVATE: public
      FORGEJO__repository__ENABLE_PUSH_CREATE_USER: "true"
      FORGEJO__repository__ENABLE_PUSH_CREATE_ORG: "true"
      FORGEJO__security__INSTALL_LOCK: "true"
      FORGEJO__session__PROVIDER: memory
      FORGEJO__log__LEVEL: Info
      FORGEJO____APP_NAME: "hacktivism git"
      FORGEJO__ui__DEFAULT_THEME: hacktivism
      FORGEJO__ui__THEMES: hacktivism,forgejo-auto,forgejo-light,forgejo-dark,gitea-auto,gitea-light,gitea-dark
    ports:
      - "9024:3000"
      - "9200:2222"
    volumes:
      - ./data:/var/lib/gitea
      - ./config:/etc/gitea
      - /etc/localtime:/etc/localtime:ro
    depends_on:
      db:
        condition: service_healthy
    labels:
      org.hacktivism.service: forgejo
      org.hacktivism.variant: rootless
      org.hacktivism.host_port: "9024"
      org.hacktivism.ssh_port: "9200"
      org.hacktivism.site: git.hacktivism.ch
      org.hacktivism.managed_by: koopa-admin
    healthcheck:
      test: ["CMD", "wget", "-q", "--spider", "http://127.0.0.1:3000/api/healthz"]
      interval: 30s
      timeout: 10s
      retries: 10
      start_period: 90s

  db:
    image: docker.io/library/postgres:16-alpine
    container_name: koopa-forgejo-db
    restart: unless-stopped
    environment:
      POSTGRES_USER: forgejo
      POSTGRES_PASSWORD: ${FORGEJO_DB_PASSWORD}
      POSTGRES_DB: forgejo
    volumes:
      - db-data:/var/lib/postgresql/data
    healthcheck:
      test: ["CMD-SHELL", "pg_isready -U forgejo -d forgejo"]
      interval: 5s
      timeout: 5s
      retries: 20
      start_period: 10s

volumes:
  db-data:
