volumes:
  postgres:
    driver: local
  gitea:
    driver: local

services:
  postgres:
    image: docker.io/library/postgres:14
    container_name: postgres
    restart: always
    environment:
      - POSTGRES_USER=${POSTGRES_USER}
      - POSTGRES_PASSWORD=${POSTGRES_PASSWORD}
      - POSTGRES_DB=${POSTGRES_DB}
    volumes:
      - postgres:/var/lib/postgresql/data
    ports:
      - "5432:5432"
    healthcheck:
      test: [ "CMD-SHELL", "pg_isready -U ${POSTGRES_USER} -d ${POSTGRES_DB}" ]
      interval: 5s
      timeout: 5s
      retries: 5
      start_period: 5s

  gitea:
    image: docker.io/gitea/gitea:1.22.6
    container_name: gitea
    restart: always
    environment:
      - GITEA__database__DB_TYPE=postgres
      - GITEA__database__HOST=postgres:5432
      - GITEA__database__NAME=${POSTGRES_DB}
      - GITEA__database__USER=${POSTGRES_USER}
      - GITEA__database__PASSWD=${POSTGRES_PASSWORD}
    volumes:
      - gitea:/data
      - /etc/timezone:/etc/timezone:ro
      - /etc/localtime:/etc/localtime:ro
    ports:
      - "3000:3000"
      - "22:22"
    depends_on:
      postgres:
        condition: service_healthy

  lsp-c:
    image: clangd:latest
    build:
      context: ./lsp/clangd
      dockerfile: Dockerfile
    container_name: lsp-c
    restart: always
    ports:
      - "30001:3000"

  lsp-cpp:
    image: clangd:latest
    build:
      context: ./lsp/clangd
      dockerfile: Dockerfile
    container_name: lsp-cpp
    restart: always
    ports:
      - "30002:3000"
