Create a basic GitLab CI config:
$ cat .gitlab-ci.yml
image: node
before_script:
- npm install
Scenario: same git provider, for this example GitHub (this trick is provider agnostic, has been tested with GitLab as well), and we want to have SSH configured for two different users (or more): jesugmz and myseconduser.
Configure SSH config in order to get an alias with different configuration as follow:
$ cat ~/.ssh/config
This is a portion of a Makefile where I select a Git tag, validate its name using regular expresion and build a Docker image with it as tag.
# it is evaluated when is used (recursively expanded variable)
# https://ftp.gnu.org/old-gnu/Manuals/make-3.79.1/html_chapter/make_6.html#SEC59
git_tag = $(shell git describe --abbrev=0 --tags)
# Semantic versioning format https://semver.org/
tag_regex := ^v([0-9]{1,}\.){2}[0-9]{1,}$
Consider the following scenario:
Problem The execution of a shell command (Radon in this example) does not retrieve an status code different to 0 when there is output (if there is output there are issues). The command does not gives parameter to handle it.
Check if the length of the output is non empty (-n
).
Docker Hub automated builds are nice to build automatically Docker images when code is pushed to the linked git repository but they do not support Docker multi-stages by default.
To do so is needed to override the default commands that Docker Hub uses internally by using hooks.
In this example we have two stages:
dev
will be built from master branch onlyprod
will be built per git tagJust add the following flag: pytest -W ignore::DeprecationWarning
More info
Check Docker Swarm labels of a specific Docker Swarm node:
docker node inspect --format '{{ .Spec.Labels }}' node-general-2
In this example we want to see the labels of the node named node-general-2.
fleet has been deprecated https://coreos.com/blog/migrating-from-fleet-to-kubernetes.html
Cloud init has been deprecated https://coreos.com/os/docs/latest/provisioning.html#using-container-linux-configs
Default time zone is UTC, recommended to avoid confusion between different zones https://coreos.com/os/docs/latest/configuring-date-and-timezone.html
Container Linux Config specification https://coreos.com/os/docs/latest/configuration.html
Real example about how to generate and add a Let's Encrypt SSL/TLS certificates to a dockerized Nginx under a running Docker Swarm using Cloudflare DNS to enable HTTPS.