0

I'm trying to build docker container using GitLab runner. (lead dev left company, and now I have no idea how to do it.)

I'll share everything I can.

Build output output error

as I understand from output runner is assigned correctly, the problem is with docker

the runner is running as Shell executor

here is .gitlab-ci.yml

stages:
  - build
  - deploy

variables:
  STACK_NAME: isnta_api
  VERSION: ${CI_COMMIT_TAG}
  IMAGE_NAME: ${DOCKER_REGISTRY}/${CI_PROJECT_PATH}:${CI_COMMIT_TAG}

before_script:
  - echo $CI_REGISTRY_PASSWORD | docker login -u $CI_REGISTRY_USER $CI_REGISTRY --password-stdin
  - echo $STACK_NAME
  - echo $CI_REGISTRY
  - echo $IMAGE_NAME

build:
  stage: build
  only:
    - tags
  script:
    - docker build -f Dockerfile -t ${IMAGE_NAME}  .
    - docker push ${IMAGE_NAME}

deploy:
  stage: deploy
  only:
    - tags
  script:
    - docker stack deploy --with-registry-auth --compose-file docker-compose.yml ${STACK_NAME}

docker-compose.yml

version: '3.7'

services:
  app:
    container_name: ${STACK_NAME}
    image: ${IMAGE_NAME}
    environment:
      PORT: 4042
      APP_ENV: production
      INSTAGRAM_API_KEY: my-api-key
      INSTAGRAM_API_HOST_NAME: instagram-bulk-profile-scrapper.p.rapidapi.com
      INSTAGRAM_API_BASE_URL: https://instagram-bulk-profile-scrapper.p.rapidapi.com/clients/api/ig/
    networks:
      - nxnet
    ports:
      - 4042:4042
    deploy:
      replicas: 1
      update_config:
        order: start-first

networks:
  nxnet:
    external: true

and Dockerfile

FROM node:14-alpine

COPY . /app

WORKDIR /app
RUN apk add --no-cache bash
RUN npm install

RUN npm run build

CMD npm run start:prod

Any suggestions or tips would be valuable. Thank you in advance

1 Answer 1

3

It looks like your Gitlab Runner does not have the capabilities to run Docker commands.

To enable your Gitlab Runner to run Docker commands you can:

  1. Modify your Gitlab Runner to use the Docker Executor
  2. Use one of the approaches in this document to enable docker commands in your existing Gitlab runner
Sign up to request clarification or add additional context in comments.

1 Comment

#2 worked perfectly, installed gitlab-runner, granted docker permissions, and it worked. Thank you.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.