services:
  database:
    image: postgres
    restart: always
    environment:
      POSTGRES_USER: postgres
      POSTGRES_PASSWORD: password
      POSTGRES_DB: haystack
    volumes:
      - ./schema.sql:/docker-entrypoint-initdb.d/schema.sql
      - ./pgdata:/var/lib/postgresql/data 
    ports:
      - 4321:5432
    healthcheck:
      test: ["CMD-SHELL", "pg_isready -U postgres -d haystack"]
      interval: 10s
      retries: 5
      start_period: 5s
      timeout: 5s
  backend:
    build: .
    restart: always
    env_file: .env.docker
    ports:
      - 3040:3040
    volumes:
      - ./.env.docker:/app/.env
    depends_on:
      database:
        condition: service_healthy
        restart: true
