services:
  frontend:
    build:
      context: .
      dockerfile: Dockerfile.frontend
      args:
        DOCKER_REGISTRY_PREFIX: ${DOCKER_REGISTRY_PREFIX:-}
    depends_on:
      - api
    ports:
      - "8080:80"

  postgres:
    image: ${DOCKER_REGISTRY_PREFIX:-}postgres:16-alpine
    environment:
      POSTGRES_DB: ${POSTGRES_DB:-llm_in_text}
      POSTGRES_USER: ${POSTGRES_USER:-llm_in_text}
      POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-llm_in_text_change_me}
    volumes:
      - ./docker-data/postgres:/var/lib/postgresql/data

  redis:
    image: ${DOCKER_REGISTRY_PREFIX:-}redis:7-alpine
    command: ["redis-server", "--appendonly", "yes"]
    volumes:
      - ./docker-data/redis:/data

  api:
    build:
      context: .
      dockerfile: backend/Dockerfile
      args:
        DOCKER_REGISTRY_PREFIX: ${DOCKER_REGISTRY_PREFIX:-}
    env_file:
      - backend/.env
    environment:
      JOB_BACKEND: redis
      REDIS_URL: redis://redis:6379/0
      DATABASE_URL: ${DATABASE_URL:-postgresql://llm_in_text:llm_in_text_change_me@postgres:5432/llm_in_text}
      DOCS_BACKEND: postgres
      JOB_SHARED_TEMP_DIR: /shared-jobs
    depends_on:
      - postgres
      - redis
    ports:
      - "8001:8001"
    volumes:
      - ./docker-data/jobs:/shared-jobs

  worker:
    build:
      context: .
      dockerfile: backend/Dockerfile
      args:
        DOCKER_REGISTRY_PREFIX: ${DOCKER_REGISTRY_PREFIX:-}
    command: ["python", "worker.py"]
    env_file:
      - backend/.env
    environment:
      JOB_BACKEND: redis
      REDIS_URL: redis://redis:6379/0
      DATABASE_URL: ${DATABASE_URL:-postgresql://llm_in_text:llm_in_text_change_me@postgres:5432/llm_in_text}
      DOCS_BACKEND: postgres
      JOB_SHARED_TEMP_DIR: /shared-jobs
    depends_on:
      - postgres
      - redis
    volumes:
      - ./docker-data/jobs:/shared-jobs
