This job retrieves Squid version and prepares the environment
variable file variables.env for subsequent jobs.
This job uses hadolint, a linter for Dockerfiles, to
ensure best practices are followed.
This job builds a Docker image for the ARM architecture using the
Squid version set in the getsquid_vars job.
After build process finishes, this job tests the Docker image built for ARM.
It tags the Docker image and pushes it to the Docker repository.
This job builds a Docker image for the AMD64 architecture using the
Squid version set in the getsquid_vars job.
After build process finishes, this job tests the Docker image built for AMD64.
Checks that the Squid configuration file is valid.
It tags the Docker image and pushes it to the Docker repository.
These jobs use dive to explore the layers of the Docker
images produced and to check for inefficiencies.
In the final step, this job updates Dockerhub repo README file with
the latest Squid version set in the getsquid_vars job.
The ChatGPT API is used in this job to create a ChatGPT Analytic report based on the pipeline processes.
Below are the details of each job, divided into their specific components:
This job navigates to a Squid Github page and retrieves the latest
Squid version. It then writes it into an environment variable
SQUID_VERSION to be used by subsequent jobs. Also, it
replaces the SQUID_VERSION place holder in the
README_template.md file with the actual version and does the same for
the DATE placeholder. After these changes, the README.md
file is updated, and the changes are committed to the git repository to
trigger a new pipeline.
InSeconds:
curl -LsXGET https://github.com/squid-cache/squid/releases/latest | grep -m 1 "Release" | cut -d " " -f4 |tr -d 'v'
- This command retrieves the latest version of Squid from GitHub
repository, and trims extra characters from the version.
echo "SQUID_VERSION=$SQUID_VERSION" > variables.env -
This command saves the latest version in a file called
variables.env. This file will be used by subsequent jobs to
fetch this version.
git add README.md &
git commit -m "README Auto update [skip ci]" || true -
These git commands add and commit the updated README.md
file to the repository.
git push https://$GITLAB_TOKEN@gitlab.com/fredbcode-images/squid.git HEAD:master || true
- The git push command that triggers a new pipeline.
This job checks Dockerfile code quality using hadolint tool which helps to enforce Dockerfile best practices and also helps to reduce the size of the resulting Docker image. If there are any best practices violation in the Dockerfile, hadolint will throw a warning or an error.
These jobs build Docker images for both ARM and AMD64 architecture
with the latest Squid version captured by getsquid_vars
job.
Commands and Actions:
docker build --build-arg SQUID_VERSION=$SQUID_VERSION --pull -t $CONTAINER_BUILD_NOPROD_NAME .
- This command uses Dockerfile to build a Docker image, and the
--build-arg flag is used to pass the latest Squid version
as an argument. Moreover, --pull flag ensures that the
image is always built from the latest base image.
docker push $CONTAINER_BUILD_NOPROD_NAME - After the
build is successful, this command pushes the image to the Docker Hub
repository.
These jobs test Docker images for both ARM and AMD64 architecture. It validates whether the Docker container is working as expected or not.
Commands and Actions:
apt update && apt install -y curl --no-upgrade --no-install-recommends --no-install-suggests
- This command updates the system package list and installs
curl package which is needed for the next step.
export https_proxy=http://$CONTAINER_TEST_NAME:3128 && curl -k https://www.google.fr
- This command sets up the Docker image as a proxy server and tries to
send a request to the google website through the Squid proxy. If the
request is delivered successfully, then the Docker image is working
properly.
This job tests the Squid configuration file in the Docker image ensuring it is valid and error-free.
Commands and Actions:
/usr/sbin/squid -k parse /etc/squid/squid.conf - The
squid -k parse command checks the syntax of the Squid.conf
configuration file. If there are any errors, it will print them to the
console.
These jobs check each layer of Docker images created for both ARM and
AMD64 architecture to identify potential waste and inefficiencies using
dive tool.
These jobs are responsible for tagging Docker images with Squid
version set in getsquid_vars job and pushing them to Docker
Hub repository.
In the last stage, this job updates Dockerhub README file with the
latest Squid version set in the getsquid_vars job.
This job uses the ChatGPT API to create analytic reports based on
pipeline processes. It specifies the model, sets up message content,
includes recent commit details, and encodes the content in JSON format.
The API request is sent using curl which returns a detailed
explanation of the pipeline, that explanation is saved in a markdown
file. Finally, the markdown file is converted to HTML and transferred to
a remote server.
variables.env - This file contains environment
variables for the pipeline jobs. It is referenced in various jobs for
fetching the Squid version that was written into it in
getsquid_vars job.
SQUID_VERSION - This environment variable is set in
getsquid_vars job. It captures the Squid version and is
used further in subsequent jobs like docker-hub-build,
docker-hub-test, push-docker-hub etc.
CONTAINER_BUILD_NOPROD_NAME_ARM,
CONTAINER_BUILD_NOPROD_NAME_AMD64 - These environment
variables contain Docker image names for ARM and AMD64 architectures.
They are defined under the variables section and used in
docker-hub-build-arm, docker-hub-build,
push-docker-hub, and
push-docker-hub-arm.
DOCKER_HUB_USER,DOCKER_HUB_TOKEN -
These environment variables are used to login to Docker Hub.
$CONTAINER_CLIENT_IMAGE - An environment variable
that specifies the base Docker image to be used in the pipeline
jobs.
Path to files - In several stages of pipeline
Dockerfile, .gitlab-ci.yml or
README.md are used from $CI_PROJECT_DIR which
is the root of the pipeline.
In Gitlab pipeline, jobs have dependencies on other jobs, they are
linked in a specific sequence so that jobs in subsequent stages only run
if the jobs in previous stages have completed successfully. Here
needs keyword is used to define job dependencies. For
instance, the docker-hub-test-arm,
docker-hub-test, push-docker-hub,
push-docker-hub-arm jobs have a dependency on
getsquid_vars job and push-docker-hub,
push-docker-hub-arm jobs have a dependency on
docker-hub-test and docker-hub-test-arm jobs.
This setup ensures that Squid version is fetched first before building
Docker images and Docker images are tested before pushing to the
repository.
Each job in the pipeline generates output which can be an image, a log or a report. For instance:
getsquid_vars: Outputs the
variables.env file. You can visit the pipeline’s “Job
Artifacts” to download it.
docker-hub-build, docker-hub-build-arm:
Outputs are Docker images which get pushed to Docker Hub.
chatgpt_analysis: Generates markdown and html
version of ChatGPT Analytic report. You can visit the pipeline’s “Job
Artifacts” to download the Markdown file.
docker-hub-test, docker-hub-test-arm:
These jobs output logs which shows whether the Squid proxy is working
correctly or not. The logs can be viewed directly in the CI/CD job logs
in GitLab.
push-docker-hub,push-docker-hub-arm:
The output of these jobs are the version tagged Docker images which get
pushed to Docker repository.
Latest Commit ID: 0e1d4d8 Commit Message: README Auto update [skip ci]
The purpose of this commit is to update the README file with the
latest Squid version. The [skip ci] in the commit message
tells GitLab to skip running CI/CD pipelines for this commit. As the
changes are only made to the README file, there is no need to run the
pipeline.