I'm trying to run E2E test in Gitlab CI.
The service is running in docker container at port localhost:3000 <-- This is parent container
Inside that container, I run docker run command for Cypress test by having cypress_baseUrl=http://localhost:3000 so that it can run test against the service hosts in parent container <-- This is child container
This is my .gitlab-ci.yml
e2e_test:
stage: e2e
extends: .sbt_base
services:
- name: "$HARBOR_REGISTRY/$DIND_IMAGE"
alias: docker
variables:
no_proxy: "${no_proxy}"
NO_PROXY: "${NO_PROXY}"
DOCKER_HOST: tcp://docker:2376
DOCKER_TLS_CERTDIR: "/certs"
DIND_IMAGE: "library/docker:19.03.14-dind"
TRUST_STORE_PATH: "${CI_PROJECT_DIR}/integration/resources/trustStore.jks"
KEYSTORE_PATH: "/usr/local/openjdk-8/jre/lib/security/cacerts"
tags:
- m1.xlarge
before_script:
- sed -i 's/localhost:/docker:/' integration/dbo/GitRepoIT.scala conf/local.conf conf/application.conf
- export TRUST_STORE_PASS=`echo $TRUST_STORE_PASS | base64 -d`
- export KEYSTORE_PASS=`echo $KEYSTORE_PASS | base64 -d`
- keytool -importkeystore -srckeystore $TRUST_STORE_PATH -destkeystore $KEYSTORE_PATH -srcstorepass $TRUST_STORE_PASS -deststorepass $KEYSTORE_PASS -noprompt
- keytool -importkeystore -srckeystore ${CI_PROJECT_DIR}/integration/resources/it-cacerts -destkeystore $KEYSTORE_PATH -srcstorepass $KEYSTORE_PASS -deststorepass $KEYSTORE_PASS -noprompt
script:
- docker-compose -f docker/docker-compose.yml build --pull
- docker-compose -f docker/docker-compose.yml up -d
- sbt "run -Dconfig.resource=local.conf"
- curl localhost:3000
- docker run cypress_baseUrl=http://localhost:3000 my.company.io/project-sample/app-cypress:latest yarn cypress:ci
Command to run service in parent container is sbt "run -Dconfig.resource=local.conf" then I curl to where my application is running which is localhost:3000 and got response back
Next I executed docker run command to create container for Cypress test. However I got this error
Cypress could not verify that this server is running:
> http://localhost:3000
We are verifying this server because it has been configured as your baseUrl.
Cypress automatically waits until your server is accessible before running tests.
I have a hunch that what I missed is --network when execute docker run command and another one wrong move is my cypress_baseUrl
Please advice.