This in-depth explanation is presented per the order of jobs in the
‘stages’ section of the .gitlab-ci.yml file.
The pipeline consists of the following stages:
Quality: Evaluates the quality of the image.Get-version: Gets the latest version of Squid.Docker-hub-build: Builds Docker images for both ARM and
AMD64 architectures.Docker-hub-test: Tests the built Docker images.Docker-hub-pushtag: Pushes the Docker images to Docker
hub.Docs: Generates documentation and analysis.hadolintThe hadolint job checks the Dockerfile syntax using a
Docker linter named hadolint.
The image used in this stage is
hadolint/hadolint:latest-debian.
hadolint:
image: hadolint/hadolint:latest-debian
stage: Quality
before_script:
- cd $CI_PROJECT_DIR
script:
- hadolint --ignore DL3008 Dockerfile script section:hadolint --ignore DL3008 Dockerfile: Lints the
Dockerfile, ignoring rule DL3008.getsquid_varsThe getsquid_vars job fetches the latest version of
Squid and creates variables.env which is used by subsequent
jobs.
The image used for this stage is defined by
$CONTAINER_CLIENT_IMAGE.
getsquid_vars:
stage: Get-version
image:
name: $CONTAINER_CLIENT_IMAGE
artifacts:
expire_in: 1 hour
paths:
- variables.env
script:
- apt update && apt install git curl ca-certificates -y --no-upgrade --no-install-recommends --no-install-suggests
- export SQUID_VERSION=$(curl -LsXGET https://github.com/squid-cache/squid/releases/latest | grep -m 1 "Release" | cut -d " " -f4 |tr -d 'v')
- echo "SQUID_VERSION=$SQUID_VERSION" > variables.env
...apt update && apt install git curl ca-certificates -y --no-upgrade --no-install-recommends --no-install-suggests:
Updates package index and installs necessary packages.export SQUID_VERSION=$(curl -LsXGET https://github.com/squid-cache/squid/releases/latest | grep -m 1 "Release" | cut -d " " -f4 |tr -d 'v'):
Fetches the latest release version of Squid and assigns it as the value
of the SQUID_VERSION environment variable.echo "SQUID_VERSION=$SQUID_VERSION" > variables.env:
Writes the SQUID_VERSION variable to
variables.env.docker-hub-build,
docker-hub-build-armThe docker-hub-build and
docker-hub-build-arm jobs build the Docker images for AMD64
and ARM architectures, respectively, and push the images to Docker
Hub.
The image used for both jobs is docker:dind, which
provides Docker in Docker capabilities, necessary for building Docker
images within a CI environment.
docker-hub-build:
image: docker:dind
....
docker-hub-build-arm:
image: docker:dind
...Both jobs contains a similar set of steps listed below:
docker login -u "$DOCKER_HUB_USER" -p "$DOCKER_HUB_TOKEN" $DOCKER_HUB_REGISTRYdocker build --build-arg SQUID_VERSION=$SQUID_VERSION --pull -t $CONTAINER_BUILD_NOPROD_NAME .--build-arg SQUID_VERSION=$SQUID_VERSION passes
the SQUID_VERSION variable as a build argument.docker push $CONTAINER_BUILD_NOPROD_NAMEdocker-hub-test,
docker-hub-test-armThe docker-hub-test and docker-hub-test-arm
jobs test the previously built Docker images by starting a container
with the image and testing if Squid is running and available.
The image used in these jobs is defined by
$CONTAINER_CLIENT_IMAGE.
Commands include:
apt update && apt install -y curl --no-upgrade --no-install-recommends --no-install-suggests:
Installs necessary packagesexport https_proxy=http://$CONTAINER_TEST_NAME:3128 && curl -k https://www.google.fr:
Sets https_proxy to use the Squid proxy server and tries to
reach google.fr.push-docker-hub and
push-docker-hub-armThese jobs push the Docker images to Docker Hub with appropriate tags.
The image used in both jobs is docker:dind, which
provides Docker in Docker capabilities, necessary for building Docker
images within a CI environment.
Steps include:
docker pull $CONTAINER_BUILD_NOPROD_NAME.docker tag $CONTAINER_BUILD_NOPROD_NAME $HUB_REGISTRY_IMAGE:$SQUID_VERSIONdocker push $HUB_REGISTRY_IMAGE:$SQUID_VERSIONdocker tag $CONTAINER_BUILD_NOPROD_NAME $HUB_REGISTRY_IMAGE:latestdocker push $HUB_REGISTRY_IMAGE:latestchatgpt_analysis, update_dockerhub_readmeThe chatgpt_analysis job initiates a ChatGPT task,
providing extensive command explanations based on the current pipeline
configuration. GPT-4 prompts include listing, explaining jobs, covering
parameters, its dependencies, outcomes, and the latest commit.
The update_dockerhub_readme job updates Docker Hub
container description with the contents of the
README.md.
The last commit was titled
README Auto update and update last_squid_version [skip ci].
It is an automatic update of the README and Squid’s version without
triggering a new CI run, by using [skip ci]. The last known
Squid version is saved in ci/last_squid_version.txt and
versions are checked in the getsquid_vars job to determine
if an update occurred.