#  Licensed to the Apache Software Foundation (ASF) under one
#    or more contributor license agreements.  See the NOTICE file
#    distributed with this work for additional information
#    regarding copyright ownership.  The ASF licenses this file
#    to you under the Apache License, Version 2.0 (the
#    "License"); you may not use this file except in compliance
#    with the License.  You may obtain a copy of the License at
#
#    http://www.apache.org/licenses/LICENSE-2.0
#
#    Unless required by applicable law or agreed to in writing,
#    software distributed under the License is distributed on an
#    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
#    KIND, either express or implied.  See the License for the
#    specific language governing permissions and limitations
#    under the License.

version: "3.8"

services:

  gremlin-server-test-js:
    container_name: gremlin-server-test-js
    image: tinkerpop/gremlin-server-test:${GREMLIN_SERVER}
    build:
      context: ../../../../../
      dockerfile: docker/gremlin-test-server/Dockerfile
      args:
        - GREMLIN_SERVER=${GREMLIN_SERVER}
    ports:
      - "45940:45940"
      - "45941:45941"
      - "45942:45942"
      - "4588:4588"
    volumes:
      - ${HOME}/.groovy:/root/.groovy
      - ${HOME}/.m2:/root/.m2
      - ${ABS_PROJECT_HOME}/gremlin-test/target:/opt/gremlin-test
    healthcheck:
      test: [ "CMD-SHELL", "apk add curl && curl -f http://localhost:45940?gremlin=100-1" ]
      interval: 30s
      timeout: 10s
      retries: 30
      start_period: 30s

  gremlin-js-integration-tests:
    container_name: gremlin-js-integration-tests
    image: node:18
    volumes:
      - .:/js_app
      - ../../../../../gremlin-test/src/main/resources/org/apache/tinkerpop/gremlin/test/features:/gremlin-test
      - ../../../../../docker/gremlin-test-server:/js_app/gremlin-test-server
      - ../../../../../gremlin-tools/gremlin-socket-server/conf:/js_app/gremlin-socket-server/conf/
    environment:
      - DOCKER_ENVIRONMENT=true
    working_dir: /js_app
    command: >
      bash -c "npm config set cache /tmp --global
      && npm ci && npm run test && npm run features-docker"
    depends_on:
      gremlin-server-test-js:
        condition: service_healthy
  gremlin-socket-server:
    container_name: gremlin-socket-server-js
    image: tinkerpop/gremlin-socket-server:${GREMLIN_SERVER}
    ports:
      - "45943:45943"
