CI/CD getting started: which is the default runtime environment? Do we really need Docker to just call zip?

Hello

We’re evaluating Gitlab and the CI/CD functions seems to be great, but somehow the most important basic information is missing :frowning:

We also want to use cloud services because simple, centralized optimizations immediately have a positive impact on our planet a million times :slight_smile: Of course, this requires that cloud providers actually use resources carefully, therefore we have 4 simple, basic questions:

1) What is the default runtime for a Job in .gitlab-ci.yml?
Does the Gitlab CI/CD always start a docker container? Or is there a lightweight runtime?
If we have the following very simple script, will it run in a bash shell?

build:
  script:
    - echo "Start"

2) Is there a documentation about the default runtime environment (I guess bash)?
The runtime surely has some special CI/CD properties, like environment variables or special paths. Where can we find the documentation?

3) Is there a listing of all supported commands in the the default runtime environment (I guess bash)?

We have tried to use the very common and often used command zip in the default shell, but it reports "zip not found" :frowning:

I really hope that zip is somehow part of the basic function in the default-shell and we do not have to call something like apt-get every time to download and install a very common command - just to destroy the runtime again a few seconds later. That would be a depressing waste of energy.

4) Is there a particularly lightweight runtime environment for simple jobs (e.g. zipping only certain files)?
A simple runtime environment with common used commands would be great :slight_smile:

Thanks a lot for any help!
kind regards,
Thomas

1) What is the default runtime for a Job in .gitlab-ci.yml?
Gitlab has runners, which are the component responsible for running the jobs. These runners should specify an executor, which defines how the jobs will be run. For example docker executor connects to a docker daemon and creates containers to run your jobs inside them.

By default the projects at gitlab.com are run on shared runners which are hosted in Gitlab Build Cloud (in gcp). You can find the list of available runners in settings/ci_cd section in your project.
image

Once you job is created it gets picked by one of the shared runners available in your instance (in this case gitlab.com). Most of the shared runners use docker+machine executor.

So to answer you question, when you run this, it will create a container and runs your script inside it.

build:
  script:
    - echo "Start"

2) Is there a documentation about the default runtime environment (I guess bash)?
Yeah look for runners and executors!

In case of the Docker executor, a default docker image and a default entrypoint are specified when configuring the gitlab runner. (in case the default image is ruby:2.5).

You can override it in the job/pipeline level by specifying your own docker image.

build:
  image: ubuntu:20.10
  script:
    - echo "Start"

or in default, to make all the jobs use it.

default:
  image: ubuntu:20.10

3) Is there a listing of all supported commands in the the default runtime environment (I guess bash)?
No there isn’t! you can list the installed binaries yourself using linux commands, for example

ls /bin /sbin /usr/bin /usr/sbin }

Is there a particularly lightweight runtime environment for simple jobs (e.g. zipping only certain files)?
Yes and No, Gitlab does not provide custom docker images for the build process, but you can do it yourself. Either look for lightweight custom docker images in docker hub, or build a docker image yourself

FROM alpine-latest
RUN apk update && apk add zip

or

FROM ubuntu:20.04
RUN apt update && apt install zip

Then build and push you image into docker hub or gitlab container registry and use in you .gitlab-ci.yml like this

docker build -t https://registry.gitlab.com/username/project:latest .
docker push https://registry.gitlab.com/username/project:latest

Then in gitlab-ci.yml

build:
  image: https://registry.gitlab.com/username/project:latest
  script:
    - zip my-file.txt
1 Like

Good morning @Iduoad

I am speechless… thank you very much for your great, fast and detailed answer!..,
I have watched several CI/CD videos from GitLab Developer Evangelists, but these simple basics were always skipped somehow.

And the GitLab documentation is extensive, but the big picture was always missing for me.

So your answer is much more practical than several hours long videos :slight_smile:

Thanks a lot!, kind regards,
Thomas

You are welcome @Jehoshua!

If you have any additional question feel free to ask it here in the forums and tag me.