version: "3"

networks:
  gitea:
    external: false

volumes:
  gitea-data:
  postgres-data:

services:
  server:
    image: gitea/gitea:latest
    container_name: gitea
    environment:
      - USER_UID=1000
      - USER_GID=1000
      - GITEA__database__DB_TYPE=postgres
      - GITEA__database__HOST=db:5432
      - GITEA__database__NAME=gitea
      - GITEA__database__USER=gitea
      - GITEA__database__PASSWD=gitea
      # SSH Configuration
      - GITEA__server__DOMAIN=bee8333.ddns.net
      - GITEA__server__SSH_DOMAIN=bee8333.ddns.net
      - GITEA__server__ROOT_URL=https://bee8333.ddns.net/
      - GITEA__server__SSH_PORT=222
      - GITEA__server__SSH_LISTEN_PORT=22
      - GITEA__server__PROTOCOL=https
      - GITEA__server__CERT_FILE=/data/gitea/cert.pem
      - GITEA__server__KEY_FILE=/data/gitea/key.pem
    restart: always
    networks:
      - gitea
    volumes:
      - gitea-data:/data
      - /etc/timezone:/etc/timezone:ro
      - /etc/localtime:/etc/localtime:ro
      - ./gitea/ssl/cert.pem:/data/gitea/cert.pem:ro
      - ./gitea/ssl/key.pem:/data/gitea/key.pem:ro
    ports:
      - "3000:3000"  # Web UI: Host port 3000 -> Container port 3000
      - "222:22"     # SSH: Host port 222 -> Container port 22
    depends_on:
      - db

  db:
    image: postgres:14
    container_name: gitea-db
    restart: always
    environment:
      - POSTGRES_USER=gitea
      - POSTGRES_PASSWORD=gitea
      - POSTGRES_DB=gitea
    networks:
      - gitea
    volumes:
      - postgres-data:/var/lib/postgresql/data 