Wiring up Behat in a project the other day, I wanted to validate Chrome connectivity in the job environment quickly - without waiting for all the steps that would ordinarily depend on, such as composer install and other build processes.
I stripped a more full featured CI job down to the bare minimum to do this and figured it's worth capturing. Here's what I used:
zenika chrome:
  image: composer
  stage: test
  needs: [  ]
  services:
    - name: zenika/alpine-chrome:latest
      alias: chrome
      command:
        - '--disable-gpu'
        - '--headless'
        - '--remote-debugging-address=0.0.0.0'
        - '--remote-debugging-port=9222'
        - '--no-sandbox'
        - '--disable-web-security'
        - '--window-size=1080,1920'
  variables:
    CHROME_URL: "http://chrome:9222"
    HOST_PORT: "build:80"
  script:
    - >
      curl --silent --show-error --header "Host: localhost" ${CHROME_URL}/json/version | tee chrome-version.json  
  artifacts:
    when: always
    name: "artifacts-${CI_JOB_NAME}-${CI_COMMIT_SHA}"
    paths:
      - chrome-version.jsonHere's that same job again, but for Pantheon's build-tools image. This one took a full minute longer to run - the image contains much more than just Chrome, so it takes longer to pull.
pantheon build tools:
  image: composer
  stage: test
  needs: [  ]
  services:
    - name: quay.io/pantheon-public/build-tools-ci:6.x
      alias: chrome
      command:
        - 'google-chrome'
        - '--disable-gpu'
        - '--headless'
        - '--remote-debugging-address=0.0.0.0'
        - '--remote-debugging-port=9222'
        - '--no-sandbox'
        - '--disable-web-security'
        - '--window-size=1080,1920'
  variables:
    CHROME_URL: "http://chrome:9222"
    HOST_PORT: "build:80"
  script:
    - >
      curl --silent --show-error --header "Host: localhost" ${CHROME_URL}/json/version | tee chrome-version.json  
  artifacts:
    when: always
    name: "artifacts-${CI_JOB_NAME}-${CI_COMMIT_SHA}"
    paths:
      - chrome-version.json