Search code examples
gitlabgitlab-cigitlab-ci-runner

gitlab build stuck on "Creating an optimized production build..."


I have got the following gitlab CI file but it is stuck on "Creating an optimized production build..."

I have tried to build the same file locally and the build is completed within 15 minutes.

What am I doing wrong here ?

image: docker:18.09.7

stages:
  - build
  - create-docker
  - deploy

variables:
  DOCKER_USER: 'xxx'
  DOCKER_PASSWORD: 'xxx'
  CI_REGISTRY: https://index.docker.io/v1/

build:
  image: node:8.16.1
  stage: build
  script:
    - npm install
    - npm run build --verbose
  artifacts:
    when: always
    expire_in: 12 hour
    paths:
      - build
  allow_failure: true

create_docker_python:
  image: docker:18.09.7
  stage: create-docker
  services:
    - docker:18.09.7-dind
  variables:
    APP_IMAGE: xyz/image:1.13
  script:
    - docker login $CI_REGISTRY -u $DOCKER_USER -p $DOCKER_PASSWORD
    - docker build -t $APP_IMAGE -f Dockerfile . && echo "Publishing docker image on $image"
    - docker push $APP_IMAGE

kube_deploy:
  before_script:
    - export KUBECONFIG=configFiles/admin.conf
  stage: deploy
  image: lwolf/helm-kubectl-docker:v152_213
  script:
    - kubectl delete ing backend
    - kubectl delete cm file-configmap
    - kubectl delete deployment saas
    - kubectl apply -f folder1/k8s/ingress.yaml --validate=false
    - kubectl apply -f folder1/k8s/k8s-deployment.yaml --validate=false
    - kubectl apply -f folder1/k8s/k8s-configmaps.yaml --validate=false

Solution

  • If your application is heavy it will require more resources and gitlab shared runner wouldn't be enough and you will have to use a dedicated runner.

    To resolve the issue I increased the RAM. I purchased a server in Digital Ocean with 16GB RAM and did npm run build or to use a dedicated runner in your CI/CD pipeline you can follow the below steps

    1. install gitlab runner
    2. register your gitlab runner

    You can follow this guide.

    https://about.gitlab.com/blog/2016/04/19/how-to-set-up-gitlab-runner-on-digitalocean/

    After increasing the RAM my build was completed in 15 minutes.