services:
  db:
    image: postgres:16-alpine
    environment:
      POSTGRES_DB: ${POSTGRES_DB}
      POSTGRES_USER: ${POSTGRES_USER}
      POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
    volumes:
      - illustrations_db_data:/var/lib/postgresql/data
    healthcheck:
      test: ["CMD-SHELL", "pg_isready -U $${POSTGRES_USER} -d $${POSTGRES_DB}"]
      interval: 3s
      timeout: 3s
      retries: 20
      start_period: 5s

  web:
    build: ./web
    env_file:
      - .env
    volumes:
      - ./web:/app
      - ./imports:/data/imports
    ports:
      - "8000:8000"
    depends_on:
      db:
        condition: service_healthy

volumes:
  illustrations_db_data:
    name: illustrations_db_data
