The basics
This page introduces the ideas and tools of the DevOps part, for someone who has never used them. Each tool then has its own page under Building blocks.
CI/CD
means automating what you would do by hand before each release:| Step | By hand | Automated here |
|---|---|---|
| Check style | run ESLint and flake8 | lint stage |
| Run the tests | npm test, pytest | test stage |
| Build the deliverable | docker build | build stage |
| Release | log into the server, restart | deploy stage |
If a step fails, the next ones do not run: broken code never goes live.
Pipeline, stage, job, runner
- A is started by GitLab on every
git push. - It is split into that run in sequence:
lint→test→build→deploy. - Each stage holds jobs:
api:test,web:test… Jobs in the same stage run in parallel. - A is the program that runs the jobs. GitLab only hands out the work.
It is all described in .gitlab-ci.yml. See GitLab CI.
Docker: image and container
packs an application with everything it needs.- The is the recipe.
- The is the ready meal, frozen, that can be moved around.
- The is the image running.
An image built by the pipeline runs exactly the same in prod. No more "it works on my machine". See Docker, Compose and Swarm.
Registry
The is the image store. The pipeline pushes images to it; prod pulls them from it. Here, it is the Container Registry built into GitLab.
Reverse proxy and HTTPS
One server, several applications: who gets the request? The listens on ports 80 and 443, looks at the requested domain name, and passes the request to the right container. It also handles . Here, it is . See Traefik.
Infrastructure as Code
Installing Docker, opening ports, registering a runner: everything is written in files, versioned in the repository. A server can be rebuilt from scratch with one command, and each change is reviewed in a merge request. See Ansible.
Secrets
A (password, key, token) never goes into Git. Here, secrets are stored in two places: GitLab's CI/CD variables and an encrypted Ansible Vault file. See Secrets and access.
Zero downtime
A deployment starts the new version, waits for it to answer, and only then stops the old one. If the new one does not answer, the old one is kept (). See Zero-downtime deployment.