# A Dockerfile for development/testing

version: "3.5"

services:
  web:
    container_name: "bonfire_web"
    build:
      context: .
      dockerfile: "Dockerfile.dev"
    ports:
      - "4000:4000"
    env_file:
      - config/dev/.env
    environment:
      - POSTGRES_HOST=db
      - SEARCH_MEILI_INSTANCE=http://search:7700
    depends_on:
      - db
        # - condition: service_healthy
      - search
    volumes:
      # - /etc/passwd:/etc/passwd:ro 
      - type: bind
        source: .
        target: /opt/app
      # do not mount the following:
      # - /opt/app/_build
      # - /opt/app/assets/node_modules
      - /opt/app/data/postgres 
      - /opt/app/data/search
    stdin_open: true # like docker run -i
    tty: true # like docker run -t
    user: $UID:$GID
  db:
    image: ${DB_DOCKER_IMAGE}
    # volumes:
      # - ./data/postgres/dev:/var/lib/postgresql/data:z
      # - /etc/passwd:/etc/passwd:ro 
    ports:
      - "5432:5432"
    env_file:
      - config/dev/.env
    # user: $UID:$GID
    healthcheck:
      test: ["CMD-SHELL", "pg_isready -U postgres"]
      interval: 10s
      timeout: 5s
      retries: 5
  search:
    image: getmeili/meilisearch:latest
    ports:
      - "7700:7700"
    # volumes:
      # - "./data/search/dev:/data.ms"
      # - /etc/passwd:/etc/passwd:ro 
    env_file:
      - config/dev/.env
    # user: $UID:$GID
