The pipeline includes several jobs ordered in different stages labelled as - Quality, Get-version, Docker-hub-build, Docker-hub-test, Docker-hub-pushtag, Docker-hub-build-arm, Docker-hub-test-arm, Docker-hub-pushtag-arm, test, and Docs.
This job runs the ‘hadolint’ docker linter on Dockerfile to ensure that the Dockerfile adheres to the best practices. It uses the latest version of the hadolint image.
This job produces an in-depth explanation of the CI/CD pipeline, constructs detailed queries for a GPT-4 model and saves the AI’s detailed response as a markdown document.
In this job, the Arm version of the Docker image is built. It logs into Docker Hub and builds and pushes a Docker image with Squid installed.
This job tests the ARM version of the Docker image, focuses on ensuring the squid proxy within the built Docker image is working as expected.
This job is responsible for tagging and pushing the ARM version of the Docker image to Docker Hub.
This job retrieves the version of Squid installed in the Docker image and updates a variables.env file. If a new version is found, a commit is made to update the README.md along with the last known version file.
Similar to docker-hub-build-arm, but for AMD64 architecture.
This job tests the AMD64 Docker image, with a focus on ensuring the Squid service within the Docker image is working properly.
Pushes the AMD64 Docker image to Docker Hub.
This job is responsible for updating the README of Docker Hub with the README from the project.
Let’s go over each of the CI/CD Pipeline’s jobs in detail from the start till the end:
hadolint job in the Quality stage focuses primarily
on code quality.hadolint --ignore DL3008 Dockerfile The above command is used to ensure the Dockerfile adheres to the best practices.
This job in the Docs stage produces an in-depth explanation of the CI/CD pipeline and analyzes the ChatGPT.
source variables.envThe source variables.env command is used to import the
environment variables defined in the variables.env file
into the current shell.
SQUID_VERSION=squid-$SQUID_VERSIONThis command sets a new environment variable,
SQUID_VERSION, using the value from the existing
environment variable, $SQUID_VERSION.
JOBS_CONTENT=$(cat .gitlab-ci.yml gitlabci/*)The cat command is used to concatenate and display the
contents of input files and in the example above, it is used to read the
contents of GitLab CI configuration files, which are then stored in
JOBS_CONTENT variable.
The docker-hub-build-arm job in the Docker-hub-build
stage builds the Docker image for Arm architecture.
docker build -f Dockerfile --build-arg SQUID_VERSION=$SQUID_VERSION --pull -t $CONTAINER_BUILD_NOPROD_NAME_ARM .The above Docker build command builds a Docker image from a
Dockerfile and a context. The build’s context is the files
at a specified location . or in simpler terms, the current
directory.
The docker-hub-test-arm job in the Docker-hub-test stage
tests the Docker image built for Arm architecture.
export https_proxy=http://$CONTAINER_TEST_NAME:3128 && curl -k https://www.google.frThis command uses curl to fetch google’s french homepage through the squid proxy to test if the proxy server is working.
The push-docker-hub-arm job will tag and push the Docker
image built for Arm architecture to Docker Hub.
docker tag $CONTAINER_BUILD_NOPROD_NAME_ARM $HUB_REGISTRY_IMAGE:$SQUID_VERSION-arm This command is responsible for tagging the image with the specified version.
The getsquid_vars job retrieves the version of squid
from the Docker image.
export SQUID_VERSION=$(curl -LsXGET https://github.com/squid-cache/squid/releases/latest | grep -m 1 "Release" | cut -d " " -f4 |tr -d 'v')The above command uses curl to fetch the HTML page of squid’s releases page on GitHub. Then grep, cut and tr are used to parse the version from the HTML.
The job docker-hub-build builds a Docker image for the
AMD64 architecture. This job is similar to
docker-hub-build-arm.
This job tests the AMD64 Docker image, with a focus on ensuring the Squid service within the Docker image is working properly.
The push-docker-hub job will tag and push the Docker
image built for the AMD64 architecture to Docker Hub.
The update_dockerhub_readme job is responsible for
updating the README file of the Dockerhub.
Throughout the jobs mentioned above, many environment variables are used such as:
Files that are referenced throughout the jobs:
The dependencies between jobs can be seen in the ‘needs’ attribute of each job. ‘needs’ specify dependencies between jobs and stages. The specified jobs need to complete before current jobs starts.
docker-hub-test-arm needs getsquid_vars
and docker-hub-build-arm to complete before it can
start.push-docker-hub-arm needs getsquid_vars
and docker-hub-test-arm to complete.docker-hub-test needs docker-hub-build to
finish.push-docker-hub needs docker-hub-test and
getsquid_vars to finish.At the end of some jobs, artifacts and Docker images are created and pushed to Docker Hub.
variables.env file is an artifact created at the
end of getsquid_vars job.docker-hub-build-arm produces a Docker image for ARM
architecture.docker-hub-build produces a Docker image for AMD64
architecture.chatgpt_analysis job produces markdown documents
and the latest markdown document is scp’d to
https://e2guardian.numsys.eu.This commit performed a Readme auto-update and an update to
last_squid_version where [skip ci] is added to
prevent the jobs from running again. This might be done to save on the
build time and resources. This does not impact the pipeline as such but
prevents it from being run unnecessarily.