skip to Main Content

I’m trying to setup a gitlab ci/cd pipeline for a vuejs application. The Gitlab runner has been created using Gitlab operator in Openshift environment. Since I need docker image of the application I’m also using buildah tool build docker image from vuejs application.

Now buildah gets installed in Gitlab runner and able to read the Dockerfile from parent directory. But when the runner reaches the npm install command in the dockerfile it throws the following error. I tried adding config.toml files, added memory to the runner. But nothing seems to be working.

.gitlab-ci.yml

image: imagesite.com/fedora:latest

variables:
  KUBERNETES_CPU_REQUEST: 3
  KUBERNETES_CPU_LIMIT: 5
  KUBERNETES_MEMORY_REQUEST: 2Gi
  KUBERNETES_MEMORY_LIMIT: 4Gi
  STORAGE_DRIVER: vfs
  BUILDAH_FORMAT: docker
  BUILDAH_FILE: Dockerfile
  GIT_SSL_NO_VERIFY: 1
  IMAGE_BUILD: buildah build-using-dockerfile
                       --format docker
                       --file Dockerfile
                       --tag
build:
  stage: build
  tags:
    - cu-admin
  script:
    - pwd
    - dnf -y install runc buildah
    - buildah images
    - echo $REGISTRY_LOGIN
    - $REGISTRY_LOGIN
    - $IMAGE_BUILD myvuejsapp:latest .

Dockerfile:

FROM node:16.1.0-slim AS NPM_BUILD
WORKDIR /app
COPY ./package.json package.json
COPY ./.env.production.local .env.production.local
COPY ./package-lock.json package-lock.json
COPY ./public public
COPY ./src src
RUN npm install
RUN npm run build

FROM nginx:1.17
COPY ./nginx.conf /etc/nginx/nginx.conf
WORKDIR /code
COPY --from=NPM_BUILD /app/dist .

EXPOSE 8082:8082
CMD ["nginx", "-g", "daemon off;"]

Error from Runner while Building:

STEP 8: RUN npm install
error running container: error from runc creating container for [/bin/sh -c npm install]: time="2021-07-30T07:47:54Z" level=warning msg="unable to get oom kill count" error="no directory specified for memory.oom_control"
time="2021-07-30T07:47:54Z" level=error msg="container_linux.go:380: starting container process caused: process_linux.go:385: applying cgroup configuration for process caused: mkdir /sys/fs/cgroup/cpuset/buildah-buildah541202824: read-only file system"
: exit status 1
error building at STEP "RUN npm install": error while running runtime: exit status 1
time="2021-07-30T07:47:54Z" level=error msg="exit status 1"

How to resolve the above error and install the npm sucessfully?

2

Answers


  1. Try using

    buildhah --isolation chroot
    
    Login or Signup to reply.
  2. I had a similar error trying to run dnf install while building an image within a container. The other answer helped me, but the syntax is wrong… --isolation is an option to the build subcommand, not buildah itself.

    Try:

    buildah build --isolation chroot <insert other arugments here>
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search