networks:
  forgejo:
    external: false

services:
  server:
    build:
      context: .
    container_name: forgejo
    env_file:
      - .env
    environment:
      - USER_UID=1000
      - USER_GID=1000
      - FORGEJO__database__DB_TYPE=postgres
      - FORGEJO__database__HOST=db
      - FORGEJO__database__NAME=$DB_NAME
      - FORGEJO__database__USER=$DB_USER
      - FORGEJO__database__PASSWD=$DB_PASSWORD
    restart: always
    networks:
      - forgejo
    volumes:
      - ./forgejo:/data
      - /etc/timezone:/etc/timezone:ro
      - /etc/localtime:/etc/localtime:ro
    ports:
      - ${APP_PORTS}
      - "222:22"
    depends_on:
      - db

  db:
    image: postgres:17
    restart: always
    environment:
      - POSTGRES_USER=$DB_USER
      - POSTGRES_PASSWORD=$DB_PASSWORD
      - POSTGRES_DB=$DB_NAME
    networks:
      - forgejo
    volumes:
      - ./postgres:/var/lib/postgresql/data