---
  version: "3.7"
  services:
    frontend:
      restart: on-failure
      build:
        context: ./frontend/
        dockerfile: ./docker/Dockerfile.cypress
      ports:
        - 8080:8080
      env_file:
        - ./test_environment/frontend.env
      environment:
        - VUE_APP_MAPBOX_TOKEN
        - VUE_APP_SAMSARA_API_KEY
        - CYPRESS_VUE_APP_MAPBOX_TOKEN
        - VUE_APP_ADMIN=true
        - VUE_APP_DEVELOPER_ID
        - CYPRESS_JWT_TESTING_TOKEN
        - VUE_APP_HEALTH_API
      volumes:
        # share everything BUT node_modules from the host
        - .:/app
        - /app/frontend/.nyc_output/
      depends_on:
        - gateway
        - health_api
      links:
        - gateway
        - health_api
    cypress:
      # version needs to match what's listed in package.json
      image: 'cypress/included:4.9.0'
      # chrome will occasionally crash in docker without this line
      # https://github.com/cypress-io/cypress/issues/350
      ipc: host
      entrypoint: /app/frontend/scripts/wait-for-it/wait-for-it.sh frontend:8080 --timeout=0  -- /app/frontend/docker/e2e_entrypoint.sh
      working_dir: /app/frontend
      env_file:
        - ./test_environment/frontend.env
      environment:
        - VUE_APP_MAPBOX_TOKEN
        - VUE_APP_SAMSARA_API_KEY
        - CYPRESS_VUE_APP_MAPBOX_TOKEN
        - VUE_APP_ADMIN=true
        - VUE_APP_DEVELOPER_ID
        - CYPRESS_JWT_TESTING_TOKEN
        - VUE_APP_HEALTH_API
      volumes:
        # share everything BUT node_modules from the host
        - .:/app
      depends_on:
        - gateway
        - health_api
        - frontend
      links:
        - gateway
        - health_api
        - frontend
