I have a docker-compose.yml that looks like this:
version: '3.8'
services:
  api:
    container_name: todoapp-api
    build:
      context: .
      dockerfile: Dockerfile
    ports:
      - 3333:3333
    depends_on:
      postgresdb:
        condition: service_healthy
  postgresdb:
    image: postgres:13
    restart: unless-stopped
    environment:
      - POSTGRES_USER=myuser
      - POSTGRES_PASSWORD=mypassword
      - POSTGRES_DB=mydb
    volumes:
      - postgres:/var/lib/postgresql/data
    ports:
      - '5432:5432'
    healthcheck:
      test: ['CMD-SHELL', 'pg_isready']
      interval: 10s
      timeout: 5s
      retries: 5
volumes:
  postgres:
Problem is that I keep getting the error code P1001 when I run this. I figured adding a healthcheck would do the trick but that doesn't work. Plus, depends_on: seems to not be present in v3 above. Is there a way I can write a script for maybe my package.json to wait for the database to be up?
 
    