1

GitLab Pipeline Output

GitLab CI/CD YML file

image: docker:latest
services:
  - docker:dind

stages:
  - test

test_stage:
    stage: test
    tags: 
      - def
    before_script:
      - apk version
      - apk add --no-cache docker-compose
      - docker info
      - docker-compose --version
    script: 
      - echo "Building and testing"
      - docker-compose up --abort-on-container-exit

Dockerfile

FROM node:10.15.3 as source
COPY package.json ./
COPY package-lock.json ./
RUN node -v
RUN npm -v
RUN npm install
COPY . ./
RUN npm run build

FROM nginx:1.15.9
COPY default.template /etc/nginx/conf.d/default.conf
CMD ["nginx", "-g", "daemon off;"]

'npm run build' from the Dockerfile runs 'webpack --mode production' which attempts to start my app on localhost within Docker. Instead, GitLab is getting stuck in 'npm run build'.

This works locally with Docker but not on the GitLab CI/CD runner, it seems to be hanging there and potentially having an out of memory error, which I received earlier when it was hanging even longer.

Why is the GitLab runner getting stuck on 'webpack --mode production' (my npm run build command)? Should I only be using 'webpack -p"?

  • 1
    Can you share the full script responsible for running the pipeline (including the dockerfile)? There is a lot that can go wrong. – Pavel Sapehin Jul 18 '21 at 03:52
  • Sure, edited original question – Parth Parulekar Jul 18 '21 at 18:59
  • 1
    I would first get rid of coping "package-lock.json", it seems it's not useful here and may cause troubles. It seems, like you have a package conflict which may have nothing in common with those build scripts. Also, it may be related to https://stackoverflow.com/questions/55271798/browserslist-caniuse-lite-is-outdated-please-run-next-command-npm-update-cani – Pavel Sapehin Jul 19 '21 at 04:08
  • I was encountering an 'npm install' fail error before very similar to these issues: https://stackoverflow.com/questions/65396985/npm-install-in-docker-container-fails-and-returns-the-command-bin-sh-c-npm-i and https://stackoverflow.com/questions/65234362/should-i-copy-package-lock-json-to-the-container-image-in-dockerfile - both of which recommended to copy package-lock.json, which fixed my original issue, maybe copying package-lock.json has too many dependencies listed and may be the culprit of my new problem – Parth Parulekar Jul 19 '21 at 07:12
  • very confusing question that does not seem to include outputs matching with the problem you describe.... please clarify and compactify – Bernard Hauzeur Mar 10 '23 at 10:21

1 Answers1

1

About maven and npm RUN steps that hang indefinitely in a Docker-in-docker context in gitlab CI runners:

Check that you do not have a DNS or other networking issue (firewall, proxy, etc.) by:

  • either connecting as a terminal to the hanging gitlab runner instance, and execute for instance a wget
  • or RUN wget https://hanging-url-here in the gitlab-ci script before your RUN docker build

When that works, there's no core networking or DNS issue on the runner host. Upon such condition, try in your gitlab-ci scripts:

docker build --network host -t $REPO_IMAGE_TAG .

The extra option tells docker to use the built-in 'host' network driver (i.e. access the gitlab-runner networking stack directly) in place of the default 'bridge' mode.

Bernard Hauzeur
  • 2,317
  • 1
  • 18
  • 25