image: docker:latest
services:
  - name: docker 19.03.12-dind
    alias: docker

stages:
  - build

build_test_frontend:
  stage: build
  services:
    - docker:19.03.12-dind
    - name: selenium/standalone-chrome
      alias: chrome

  variables:
    APP_TESTS_REMOTE_WEB_DRIVER_URL: "http://chrome:4444"

  script: 
    - echo "install npm"
    - apk update
    - apk upgrade
    - apk add --update nodejs npm
    - echo "Starte den Build"
    - npm install
    - echo "Install erfolgreich"
    - CI=false npm run build
    - echo "Build erfolgreich"
    - docker pull registry.bht-berlin.de:443/s87777/profwebbackend:latest
    - docker run --name backend_container -d registry.bht-berlin.de:443/s87777/profwebbackend
    - echo "docker commands success"
    - npm start &
    - echo "start test"
    - npm test --host=$SELENIUM_HOST
    - echo "Testing finshed"

  tags: 
    - docker-privileged
  artifacts:
    expire_in: 1 hour
    paths:
      - build
      - node_modules/