In my gitlab CI I am trying to run some Nightwatch.js tests on a nextjs app. To avoid exposing API keys to my app, I have created a microservice which proxies requests to my actual api.
The proxy service is a simple express app that listens on port 3001. Here is it’s Dockerfile which is available at registry.gitlab.com/acha5066/wedgie-travel-proxy:latest for the main CI process to use.
FROM node:12-buster # This image will be built in CI on deploy. COPY . /home/node/app/ WORKDIR /home/node/app/ EXPOSE 3001 CMD yarn server
Here is my .gitlab-ci.yml
image: registry.gitlab.com/acha5066/wedgie-travel/node:12-buster-1 services: - name: registry.gitlab.com/acha5066/wedgie-travel-proxy:latest alias: proxy stages: - build - test yarn: stage: build script: # Build and serve app. - cd $CI_PROJECT_DIR/public && yarn install - yarn global add grunt-cli - grunt build - cd $CI_PROJECT_DIR/public && yarn build artifacts: paths: - $CI_PROJECT_DIR/public/.next - $CI_PROJECT_DIR/public/node_modules tests: stage: test script: - cd $CI_PROJECT_DIR/public && yarn start & # Starts the server in the background. - sleep 5 # Wait for server to start. - curl proxy:3001 - cd $CI_PROJECT_DIR/public && ./node_modules/.bin/nightwatch artifacts: paths: - $CI_PROJECT_DIR/public/tests_output - $CI_PROJECT_DIR/public/geckodriver.log - $CI_PROJECT_DIR/public/chromedriver.log when: always
As you can see, I’m trying to simply curl the service alias and the port
(curl proxy:3001) but I am continually getting connection refused. So how do I find the port to use for my service. If I expose port 3001 in the Dockerfile should it not be available there from curl.
Help appreciated as I’m stuck