services:
  hoppscotch-db:
    image: postgres:15-alpine
    container_name: hoppscotch-db
    restart: unless-stopped
    environment:
      POSTGRES_USER: ${POSTGRES_USER}
      POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
      POSTGRES_DB: ${POSTGRES_DB}
    volumes:
      - ./postgres-data:/var/lib/postgresql/data
    healthcheck:
      test: ["CMD-SHELL", "pg_isready -U ${POSTGRES_USER} -d ${POSTGRES_DB}"]
      interval: 10s
      timeout: 5s
      retries: 5
    networks:
      - hoppscotch-network

  hoppscotch:
    image: hoppscotch/hoppscotch:latest
    container_name: hoppscotch-aio
    restart: unless-stopped
    env_file:
      - .env
    ports:
      - "127.0.0.1:3000:80"
      - "127.0.0.1:3170:8080"
    depends_on:
      hoppscotch-db:
        condition: service_healthy
    networks:
      - hoppscotch-network

networks:
  hoppscotch-network:
    driver: bridge
