services:
  yb:
    build: .
    container_name: yb
    ports:
      - "127.0.0.1:5433:5433"
    volumes:
      - certs:/app/generated_certs
    healthcheck:
      test: 'ysqlsh -h $$(hostname) -c \\conninfo || exit 1;'
      interval: 2s
      timeout: 30s
      retries: 20
      start_period: 10s

  pg:
    image: ruby:3.0
    working_dir: /app
    volumes:
      - .:/app
      - certs:/generated_certs
    command: bash -c "gem inst pg-*.gem && ruby pg-test.rb"
    depends_on:
      yb:
        condition: service_healthy

volumes:
  certs:
