version: '2.1'

services:
  postgres:
    logging:
      driver: none
    image: "postgres:9.3.24"
    environment:
      POSTGRES_PASSWORD: "secret"
      POSTGRES_USER: "health_api"
    ports:
      - "5432:5432"
    healthcheck:
      test: ["CMD-SHELL", "pg_isready -U postgres"]
      interval: 5s
      timeout: 5s
      retries: 5
  health_api:
    logging:
      driver: none
    depends_on:
      postgres:
        condition: service_healthy
    ports:
    - "8050:80"
    build:
      context: ./
      args:
        - PACKAGE_NAME=health_api
    command: migrate-and-run
    env_file:
      - ../test_environment/health_api.env
    restart: on-failure
    links:
      - postgres
    healthcheck:
      test: ["CMD-SHELL", "curl 0.0.0.0:80/health/status"]
      interval: 5s
      timeout: 5s
      retries: 5
