services:
  forgejo:
    # Stock Forgejo image — does NOT include the IFC patch from go.patch.
    # Use this to test the preview service and viewer in isolation only.
    # To test the Go patch itself, run the patched binary built from go.patch.
    image: codeberg.org/forgejo/forgejo:13
    container_name: ifcurl-forgejo
    restart: unless-stopped
    ports:
      - "3000:3000"   # web UI
      - "2222:22"     # SSH (avoids conflict with host sshd on 22)
    volumes:
      - forgejo-data:/data
    environment:
      # Run the container process as the current host user so files in the
      # volume are owned by you, not root.
      USER_UID: "${UID:-1000}"
      USER_GID: "${GID:-1000}"

      # Skip the interactive web installer — all required settings are
      # supplied here as environment variables.
      GITEA__security__INSTALL_LOCK: "true"

      # Database: SQLite is sufficient for local development.
      GITEA__database__DB_TYPE: sqlite3
      GITEA__database__PATH: /data/gitea/gitea.db

      # Server: tell Forgejo its own public URL so clone URLs are correct.
      GITEA__server__HTTP_PORT: "3000"
      GITEA__server__ROOT_URL: "http://localhost:3000"
      GITEA__server__SSH_PORT: "2222"
      GITEA__server__SSH_LISTEN_PORT: "22"

      # Reduce log noise during development.
      GITEA__log__LEVEL: Warn

volumes:
  forgejo-data:
    name: ifcurl-forgejo-data

# Usage:
#   podman-compose up -d            start Forgejo
#   podman-compose down             stop (data preserved)
#   podman-compose down -v          stop and wipe all data
#
# On first run, create an admin user:
#   podman exec --user git ifcurl-forgejo forgejo admin user create \
#       --username admin --password admin1234 --email admin@localhost \
#       --admin --must-change-password=false
#
# Web UI:  http://localhost:3000  (admin / admin1234)
# SSH:     ssh://git@localhost:2222/<user>/<repo>.git
# API:     http://localhost:3000/api/v1  (basic auth or token)
