networks:
  proxy:
    external: true


services:

###################
## Stack Forgejo
###################

  forgejo:
    image: codeberg.org/forgejo/forgejo:14.0.2
    container_name: forgejo
    hostname: forgejo
    restart: unless-stopped
    depends_on:
      forgejo-db:
        condition: service_healthy
#    ports:
#      - 3842:3000  # HTTP
#      - 2222:22    # SSH
    environment:
      - USER_UID=${PUID}
      - USER_GID=${PGID}
      - TZ=${TZ}
      - FORGEJO__database__DB_TYPE=postgres
      - FORGEJO__database__HOST=forgejo-db:5432
      - FORGEJO__database__NAME=forgejo
      - FORGEJO__database__USER=forgejo
      - FORGEJO__database__PASSWD=c0IAnVUAV1GNCAzog0stJJRvnz60
    volumes:
      - ${CONFIG_DIR}/forgejo/data:/data
      - /etc/timezone:/etc/timezone:ro
      - /etc/localtime:/etc/localtime:ro
    networks:
      - proxy

  forgejo-db:
    image: postgres:18-alpine
    container_name: forgejo-db
    hostname: forgejo-db
    restart: unless-stopped
    environment:
      - TZ=${TZ}
      - POSTGRES_DB=forgejo
      - POSTGRES_USER=forgejo
      - POSTGRES_PASSWORD=c0IAnVUAV1GNCAzog0stJJRvnz60
    volumes:
      - ${CONFIG_DIR}/forgejo/db:/var/lib/postgresql
    healthcheck:
      test: ["CMD-SHELL", "pg_isready -U forgejo -d forgejo"]
      interval: 10s
      timeout: 5s
      retries: 5
    networks:
      - proxy
