Reputation: 382
I have a ubuntu 18.04 server installed Gitlab-EE in it. I can access my runners and many other thing. I want to setup CI/CD with GitLab. So lets begin :
Error :
My gitlab-ci.yml
image: docker:latest
services:
- docker:dind
stages:
- build
- deploy
build:
image: node:latest
stage: build
tags:
- api
before_script:
- apt-get update -qq
- apt-get install -y
script:
- npm install
deploy:
services:
- node:latest
image: node:latest
stage: deploy
tags:
- api
script:
- sudo apt install python-pip
- sudo pip install docker-compose
- npm run dc:up ( this makes docker-composer build )
build stage completes successfully deploy stage give error.
My Gitlab Runner :
concurrent = 1
check_interval = 0
[session_server]
session_timeout = 1800
[[runners]]
name = "Api-Runner"
url = "XX"
token = "XXX"
executor = "docker"
[runners.docker]
tls_verify = false
image = "node:latest"
privileged = true
disable_entrypoint_overwrite = false
oom_kill_disable = false
disable_cache = false
volumes = ["/cache"]
shm_size = 0
[runners.cache]
[runners.cache.s3]
[runners.cache.gcs]
I want to install docker-composer for my project to run. If I remove the 'sudo' command the output gives like this
Upvotes: 1
Views: 1089
Reputation: 146
Looks like the image you are using (node:latest
) does not include the command sudo
. It also looks like it defaults to the root
user, so maybe you can just avoid using sudo
altogether?
You can explore the environment/container in which your job will be running by starting your own container from that image: docker run --rm -ti node:latest bash
If you can work it out manually by using a container like that, then you can use that recipe in your gitlab-ci.yml
file.
In particular, though, keep in mind that gitlab will start a new container for each job, so you probably want to add apt-get update -qq
to your deploy
job as well.
Upvotes: 1