################################################################################
# gitea -- https://docs.gitea.com/installation/install-with-docker
################################################################################

networks:
  gitea_net:
    driver: bridge

services:
# --- Gitea ---
  server:
    image: docker.gitea.com/gitea:1.25.4
    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_DB_USER}
      - GITEA__database__PASSWD=${GITEA_DB_PASSWORD}
    restart: always
    networks:
      - gitea_net
    volumes:
      - "${GITEA_HOME}/data:/data"
      - "/etc/timezone:/etc/timezone:ro"
      - "/etc/localtime:/etc/localtime:ro"
    ports:
      - "${GITEA_WEB_PORT}:3000"
      - "${GITEA_SSH_PORT}:22"
    depends_on:
      - db

# --- Gitea postgres db ---
  db:
    image: docker.io/library/postgres:14
    restart: always
    environment:
      - POSTGRES_USER=${GITEA_DB_USER}
      - POSTGRES_PASSWORD=${GITEA_DB_PASSWORD}
      - POSTGRES_DB=gitea
    networks:
      - gitea_net
    volumes:
      - "${GITEA_HOME}/postgres:/var/lib/postgresql/data"
      
# --- Gitea Actions Runner ---
  runner:
    image: gitea/act_runner:latest
    container_name: gitea_runner
    restart: always
    environment:
      - GITEA_INSTANCE_URL=https://git.wompmacho.com
      - GITEA_RUNNER_REGISTRATION_TOKEN=${GITEA_RUNNER_TOKEN}
      - GITEA_RUNNER_NAME=gitea-runner-01
      - CONFIG_FILE=/data/config.yaml
    volumes:
      - "${GITEA_HOME}/runner:/data"
      - "${WWW_HOME}:/deploy"
      - "${CONFIGS_HOME}:/assets"
      - "/var/run/docker.sock:/var/run/docker.sock"
    networks:
      - gitea_net
    depends_on:
      - server

# --- Nginx Web Server (Public) ---
  docs-public:
    image: nginx:alpine
    container_name: docs-public
    restart: always
    ports:
      - "${DOCS_PUBLIC_PORT}:80"
    volumes:
      - "${WWW_HOME}/docs-public:/usr/share/nginx/html:ro"
    networks:
      - gitea_net

# --- Nginx Web Server (Private) ---
  docs-private:
    image: nginx:alpine
    container_name: docs-private
    restart: always
    ports:
      - "${DOCS_PRIVATE_PORT}:80"
    volumes:
      - "${WWW_HOME}/docs-private:/usr/share/nginx/html:ro"
    networks:
      - gitea_net
