services:
  postgres:
    container_name: postgres
    image: postgres:16.9-bullseye
    environment:
      POSTGRES_USER: ${MAIN_USER}
      POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
    volumes:
      - ./init.sql:/docker-entrypoint-initdb.d/init.sql
      - /srv/cicd/postgres:/var/lib/postgresql/data
    restart: unless-stopped
    networks:
      - cicd_net

  gitea:
    container_name: gitea
    image: gitea/gitea:1.24
    environment:
      GITEA__security__SECRET_KEY: "${GITEA_SECRET_KEY}"
      GITEA__security__INTERNAL_TOKEN: "${GITEA_INTERNAL_TOKEN}"
      GITEA__server__APP_DATA_PATH: /data/gitea
      GITEA__server__DOMAIN: ${GIT_DOMAIN}
      GITEA__server__SSH_DOMAIN: ${GIT_DOMAIN}
      GITEA__server__ROOT_URL: "https://${GIT_DOMAIN}/"
      GITEA__server__OFFLINE_MODE: false
      #      GITEA__server__SSH_PORT: 22
      #      GITEA__server__SSH_LISTEN_PORT: 22
      GITEA__server__LFS_START_SERVER: true
      GITEA__server__LFS_JWT_SECRET: "${GITEA_JWT_SECRET}"
      GITEA__database__DB_TYPE: postgres
      GITEA__database__HOST: postgres:5432
      GITEA__database__NAME: gitea_db
      GITEA__database__USER: gitea
      GITEA__database__PASSWD: giteapass
      GITEA__service__DISABLE_REGISTRATION: true
      GITEA__service__REQUIRE_SIGNIN_VIEW: false
      GITEA__service__REGISTER_EMAIL_CONFIRM: false
      GITEA__service__ENABLE_NOTIFY_MAIL: false
      GITEA__service__ALLOW_ONLY_EXTERNAL_REGISTRATION: false
      GITEA__service__ENABLE_CAPTCHA: true
      GITEA__service__DEFAULT_KEEP_EMAIL_PRIVATE: true
      GITEA__service__DEFAULT_ALLOW_CREATE_ORGANIZATION: true
      GITEA__service__DEFAULT_ENABLE_TIMETRACKING: true
      GITEA__service__NO_REPLY_ADDRESS: noreply.localhost
      GITEA__service__DEFAULT_USER_IS_RESTRICTED: true
      #gitea themes
      GITEA__ui__THEMES:  ${GITEA_CATPPUCCIN}
      GITEA__ui__DEFAULT_THEME: catppuccin-latte-rosewater
      USER_ID: 1000
      USER_GID: 1000
    user: root
    volumes:
      - /srv/cicd/gitea_data:/data
      - /etc/timezone:/etc/timezone:ro
      - /etc/localtime:/etc/localtime:ro
    restart: unless-stopped
    depends_on:
      - postgres
    networks:
      - cicd_net

networks:
  cicd_net:
    external: true
