

version: "3.9"
services:
  web:
    image: frontend
    build: ../frontend
    stdin_open: true # docker run -i
    tty: true        # docker run -t
    ports:
      - "3000:3000"
    logging:
      driver: json-file
      options:
        max-size: "10m"
        max-file: "3"
  db:
    logging:
      driver: json-file
      options:
        max-size: "10m"
        max-file: "3"
    image: postgres
    volumes:
      - ./data/db:/var/lib/postgresql/data
    environment:
      - POSTGRES_HOST_AUTH_METHOD=trust
      - POSTGRES_DB=db_erp_import_validator
    ports:
      - "5432:5432"
    logging:
      driver: json-file
      options:
        max-size: "10m"
        max-file: "3"

  backend:
    image: backend
    volumes:
    - ./wait-for-it.sh:/usr/src/app/wait-for-it.sh
    - ./start-backend.sh:/usr/src/app/start-backend.sh
    build: ../backend
    environment:
     - DB_HOST=db
    ports:
     - "8080:8080"
     logging:
       driver: json-file
       options:
         max-size: "10m"
         max-file: "3"
    depends_on:
     - "db"
    

    
    command: ["bash", "./wait-for-it.sh", "db:5432", "--timeout=0", "--strict", "--", "bash", "./start-backend.sh"]
    
