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.
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: de194cf559msh8d940d38fd1ca47p129005jsnc11b4fd77a36
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
CodePudding user response:
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:
- Modify your Gitlab Runner to use the Docker Executor
- Use one of the approaches in this document to enable docker commands in your existing Gitlab runner