version: '2'
services:
  database:
    container_name: dhis2-database
    image: pgracio/dhis2-db:2.26-sierra-leone
    environment:
      POSTGRES_USER: dhis
      POSTGRES_DB: dhis
      POSTGRES_PASSWORD: dhis
      POSTGRES_DB_TARGET: dhis-target
      PG_DATA: /var/lib/postgresql/data/pgdata:z
    ports:
     - "5432:5432"
  web:
    container_name: dhis2-web
    image: dhis2/dhis2-web:2.26-tomcat7-jre8-latest
    environment:
      JAVA_OPTS: "-Xmx1024m -Xms4000m"
      POSTGRES_DB: dhis
    ports:
      - "8085:8080"
    depends_on:
      - database
    entrypoint: ./wait-for-it.sh -t 0 database:5432 --
    command: catalina.sh run # https://github.com/docker/compose/issues/3140
  api-tests:
    container_name: dhis2-api-tests
    build: .
    image: dhis2/dhis2-api-tests
    depends_on:
      - web
    entrypoint: ./wait-for-it.sh -t 0 http://web:8080 -- npm test -- --world-parameters "{\"apiEndpoint\":\"http://web:8080/api\"}"

version: '2.1'
services:
  database:
    container_name: dhis2-database
    image: pgracio/dhis2-db:2.26-sierra-leone
    environment:
      POSTGRES_USER: dhis
      POSTGRES_DB: dhis
      POSTGRES_PASSWORD: dhis
      POSTGRES_DB_TARGET: dhis-target
      PG_DATA: /var/lib/postgresql/data/pgdata:z
    ports:
     - "5432:5432"
    healthcheck:
      test: ["CMD-SHELL", "pg_isready -h database -p 5432 -d dhis2"]
      interval: 30s
      timeout: 30s
      retries: 30
  web:
    container_name: dhis2-web
    image: dhis2/dhis2-web:2.26-tomcat7-jre8-latest
    environment:
      JAVA_OPTS: "-Xmx1024m -Xms4000m"
      POSTGRES_DB: dhis
    ports:
      - "8085:8080"
    depends_on:
      database:
        condition: service_healthy
    healthcheck:
      test: "curl -f http://localhost:8080"
      interval: 15s
      retries: 120
  api-tests:
    container_name: dhis2-api-tests
    build: .
    depends_on:
      web:
        condition: service_healthy
    entrypoint: npm test -- --world-parameters "{\"apiEndpoint\":\"http://web:8080/api\"}"

Configure a check that’s run to determine whether or not containers are “healthy”. No need to use wait-for-it.sh
Configure a check that’s run to determine whether or not containers  are “healthy”. No need to use wait-for-it.sh
