In the pipeline, there are many jobs as defined in the stages of the
.gitlab-ci.yml file. Here is a brief description of
each.
getsquid_vars: This job fetches the latest Squid
version, updates README.md, commits, and pushes the changes to the
master branch.hadolint: This job runs Hadolint, which is a very
popular linting tool for Dockerfiles.docker-hub-build: This builds Docker images for AMD64
architecture using the latest Squid version.docker-hub-test: This job tests the Docker image built
in the previous stage.SquidParseConfig: This ensures that the Squid
configuration file does not have any syntax errors.dive: This analyzes and displays information of the
Docker images’ layers.push-docker-hub: This pushes the Docker image to Docker
Hub for AMD64 architecture.docker-hub-build-arm: This builds the Docker image for
the ARM architecture.docker-hub-test-arm: This tests the Docker image built
for ARM architecture.dive-arm: This analyzes and displays information of the
Docker image’s layers built for ARM architecture.push-docker-hub-arm: This pushes the Docker image to
Docker Hub for ARM architecture.chatgpt_analysis: This job allows for the review and
analysis of all the CI/CD pipeline jobs.update_dockerhub_readme: This updates the README file
on the Docker Hub registry.getsquid_varsREADME_template.md file and saves it as
README.md.script:
- 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
- sed -i "s/{{SQUID_VERSION}}/$SQUID_VERSION/g" README_template.md
- sed -i "s/{{DATE}}/$(date +%Y%m%d)/g" README_template.md
- cp README_template.md README.md
- git config user.email "fredbcode"
- git config user.name "fredbcode"
- git add README.md
- git commit -m "README Auto update [skip ci]" || true
- git push https://$GITLAB_TOKEN@gitlab.com/fredbcode-images/squid.git HEAD:master || truehadolintscript:
- hadolint --ignore DL3008 Dockerfiledocker-hub-buildbefore_script:
- docker login -u "$DOCKER_HUB_USER" -p "$DOCKER_HUB_TOKEN" $DOCKER_HUB_REGISTRY
script:
- docker build --build-arg SQUID_VERSION=$SQUID_VERSION --pull -t $CONTAINER_BUILD_NOPROD_NAME_AMD64 .
- docker push $CONTAINER_BUILD_NOPROD_NAME_AMD64docker-hub-testscript:
- export https_proxy=http://$CONTAINER_TEST_NAME:3128 && curl -k https://www.google.frSquidParseConfigscript:
- /usr/sbin/squid -k parse /etc/squid/squid.conf
- "! /usr/sbin/squid -k parse /etc/squid/squid.conf 2>&1 | grep ERROR"divescript:
- docker pull $CONTAINER_BUILD_NOPROD_NAME_AMD64
- dive $CONTAINER_BUILD_NOPROD_NAME_AMD64push-docker-hubbefore_script:
- docker login -u "$DOCKER_HUB_USER" -p "$DOCKER_HUB_TOKEN" $DOCKER_HUB_REGISTRY
script:
- docker pull $CONTAINER_BUILD_NOPROD_NAME_AMD64
- docker tag $CONTAINER_BUILD_NOPROD_NAME_AMD64 $HUB_REGISTRY_IMAGE:$SQUID_VERSION-amd64
- docker push $HUB_REGISTRY_IMAGE:$SQUID_VERSION-amd64
- docker tag $CONTAINER_BUILD_NOPROD_NAME_AMD64 $HUB_REGISTRY_IMAGE:latest-amd64
- docker push $HUB_REGISTRY_IMAGE:latest-amd64
- docker tag $CONTAINER_BUILD_NOPROD_NAME_AMD64 $HUB_REGISTRY_IMAGE:latest
- docker push $HUB_REGISTRY_IMAGE:latestThe jobs for ARM architecture (docker-hub-build-arm,
docker-hub-test-arm, dive-arm, and
push-docker-hub-arm) have the same functions but they are
built for the ARM architecture.
chatgpt_analysisupdate_dockerhub_readmeREADME.md file from the Git repository.Here are the environment variables and files used across the jobs:
variables.env: This file is created in the
getsquid_vars job and it contains the latest version of
Squid.SQUID_VERSION: This is an environment variable that
holds the latest version of Squid. It is used in various jobs for
pulling, building, tagging, and pushing Docker images.DOCKER_HUB_USER: This environment variable holds the
Docker Hub username and is used for logging into Docker Hub.DOCKER_HUB_TOKEN: This environment variable holds the
Docker Hub access token and is used for authenticating with Docker
Hub.DOCKER_HUB_REGISTRY: This environment variable holds
the Docker Hub registry URL and is used in Docker commands.GITLAB_TOKEN: This environment variable holds the
GitLab access token and is used for pushing commits.CONTAINER_BUILD_NOPROD_NAME_AMD64: This environment
variable holds the Docker image name to be used for the AMD64
architecture.HUB_REGISTRY_IMAGE: This environment variable holds the
Docker image name to be used for the ARM architecture.Several jobs are dependent on each other, as emphasized by the
needs keyword in each job configuration:
docker-hub-build depends on getsquid_vars
to get the variable SQUID_VERSION.docker-hub-test needs docker-hub-build to
build the Docker image before it can be tested.push-docker-hub needs docker-hub-test to
ensure that the Docker image has been tested before it can be
pushed.docker-hub-build-arm, docker-hub-test-arm
and push-docker-hub-arm are similar to the AMD64 jobs but
for the ARM architecture.chatgpt_analysis needs getsquid_vars,
docker-hub-test, and docker-hub-test-arm to
get the complete list of jobs for analysis.update_dockerhub_readme needs
getsquid_vars to get the latest Squid version.getsquid_vars: Produces the variables.env
file that contains an environment variable for the latest Squid
version.hadolint: Doesn’t produce any artifacts but ensures the
Dockerfile is properly linted.docker-hub-build: Builds and pushes a Docker image to
Docker Hub based on the latest Squid version.docker-hub-test: Tests the Docker image built, ensuring
it can act as a proxy for HTTP requests.SquidParseConfig: Doesn’t produce any artifacts but
ensures the Squid configuration file is syntactically correct.dive: Doesn’t produce any artifacts but provides
detailed information on the Docker image’s layers.push-docker-hub: Pushes both the latest version and the
version tag of the Docker image to Docker Hub.docker-hub-build-arm, docker-hub-test-arm,
dive-arm, push-docker-hub-arm: All these jobs
are equivalent to the AMD64 jobs but for the ARM architecture.chatgpt_analysis: The analysis is saved as a markdown
file and a HTML report is generated from that. The HTML report is copied
to a remote server and also saved as an artifact.update_dockerhub_readme: Updates the
README.md file on Docker Hub registry.The latest commit is “9790c65 README Auto update [skip ci]”. This
commit updates the README.md file inside the Git repository
with the latest Squid version and current date, but it does not trigger
a CI pipeline run, as specified by the [skip ci] tag in the commit
message. The purpose is to keep the README file up-to-date in the
repository with the latest Squid version and date. It does impact the
pipeline as any changes made to README are not supposed to trigger the
pipeline, thus it doesn’t result in redundant job runs. The “[skip ci]”
tag ensures that this commit does not trigger the pipeline.