Here are all the jobs listed in the pipeline in order as defined in the ‘stages’ section of the .gitlab-ci.yml file:
hadolint: A Docker linting tool that helps validate
Dockerfile.getsquid_vars: Retrieves Squid’s version from its
website and updates README.md with Squid’s version.docker-hub-build: Builds docker image from Dockerfile,
tags the image, and pushes it to Docker Hub.docker-hub-test: Checks if the built Docker image is
able to setup a local squid proxy.SquidParseConfig: The Squid configuration parser
validates the squid.conf file.dive: A tool for exploring docker image, layers
contents, and discovering ways to shrink the size of Docker/OCI
image.push-docker-hub: Tags a Docker image with the Squid
version and pushes it to Docker Hub.docker-hub-build-arm: Same as the
docker-hub-build but for ARM architecture.docker-hub-test-arm: Same as the
docker-hub-test but for ARM architecture.push-docker-hub-arm: Same as
push-docker-hub but for ARM images.chatgpt_analysis: Leverages OpenAi’s GPT to generate
explanations for each CI/CD job.update_dockerhub_readme: Updates Docker hub with the
newer README.hadolint command ignores rule DL3008 which suggests
using a version pinning for each package.hadolint:
image: hadolint/hadolint:latest-debian
stage: Quality
before_script:
- cd $CI_PROJECT_DIR
script:
- hadolint --ignore DL3008 Dockerfile
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 -s http://www.squid-cache.org/Versions/v6/ | egrep -m 1 -oh squid-.*.tar.gz | cut -d '"' -f1 | sed 's/\.tar\.gz//g' | sed 's/squid-//g')
- echo "SQUID_VERSION=$SQUID_VERSION" > variables.env
- echo $SQUID_VERSION
- 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 || true
docker-hub-build:
stage: Docker-hub-build
image: docker:dind
needs:
- getsquid_vars
artifacts:
expire_in: 2 hours
paths:
- $CI_PROJECT_DIR
timeout: 3 hours
before_script:
- docker login -u "$DOCKER_HUB_USER" -p "$DOCKER_HUB_TOKEN" $DOCKER_HUB_REGISTRY
script:
- source variables.env
- SQUID_VERSION=squid-$SQUID_VERSION
- docker build --build-arg SQUID_VERSION=$SQUID_VERSION --pull -t $CONTAINER_BUILD_NOPROD_NAME_AMD64 .
- docker push $CONTAINER_BUILD_NOPROD_NAME_AMD64
docker-hub-build job is able to setup a local squid
proxy.curl to check if it can access
https://www.google.fr through the local squid proxy.docker-hub-test:
stage: Docker-hub-test
extends: .services-amd64
before_script:
- apt update && apt install -y curl --no-upgrade --no-install-recommends --no-install-suggests
script:
- export https_proxy=http://$CONTAINER_TEST_NAME:3128 && curl -k https://www.google.fr
variables:
HOSTNAME: squidpipeline
needs: ["docker-hub-build"]
SquidParseConfig:
stage: Docker-hub-test
image:
name: $CONTAINER_BUILD_NOPROD_NAME_AMD64
script:
- /usr/sbin/squid -k parse /etc/squid/squid.conf
# Stop if error
- "! /usr/sbin/squid -k parse /etc/squid/squid.conf 2>&1 | grep ERROR"
dive:
image:
name: wagoodman/dive:latest
entrypoint: [""]
stage: Docker-hub-test
script:
- docker pull $CONTAINER_BUILD_NOPROD_NAME_AMD64
- dive $CONTAINER_BUILD_NOPROD_NAME_AMD64
variables:
CI: "true"
docker-hub-build
job.push-docker-hub:
stage: Docker-hub-pushtag
image: docker:dind
needs:
- docker-hub-test
- getsquid_vars
before_script:
- docker login -u "$DOCKER_HUB_USER" -p "$DOCKER_HUB_TOKEN" $DOCKER_HUB_REGISTRY
script:
- source variables.env
- 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:latest
variables:
GIT_STRATEGY: none
only:
- master
docker-hub-build-arm:
stage: Docker-hub-build
image: docker:19.03.8-dind
needs:
- getsquid_vars
artifacts:
expire_in: 2 hours
paths:
- $CI_PROJECT_DIR
timeout: 3 hours
before_script:
- docker login -u "$DOCKER_HUB_USER" -p "$DOCKER_HUB_TOKEN" $DOCKER_HUB_REGISTRY
script:
- source variables.env
- SQUID_VERSION=squid-$SQUID_VERSION
- docker build -f Dockerfile --build-arg SQUID_VERSION=$SQUID_VERSION --pull -t $CONTAINER_BUILD_NOPROD_NAME_ARM .
- docker push $CONTAINER_BUILD_NOPROD_NAME_ARM
tags:
- arm
docker-hub-test-arm:
stage: Docker-hub-test
extends: .services-arm
tags:
- arm
artifacts:
script:
- apt update && apt install -y curl --no-upgrade --no-install-recommends --no-install-suggests
- export https_proxy=http://$CONTAINER_TEST_NAME:3128 && curl -k https://www.google.fr
variables:
HOSTNAME: squidpipeline
needs: ["docker-hub-build-arm"]
push-docker-hub-arm:
stage: Docker-hub-pushtag
image: docker:19.03.8-dind
needs:
- getsquid_vars
- docker-hub-test-arm
tags:
- arm
artifacts:
before_script:
- docker login -u "$DOCKER_HUB_USER" -p "$DOCKER_HUB_TOKEN" $DOCKER_HUB_REGISTRY
script:
- source variables.env
- docker pull $CONTAINER_BUILD_NOPROD_NAME_ARM
- docker tag $CONTAINER_BUILD_NOPROD_NAME_ARM $HUB_REGISTRY_IMAGE:$SQUID_VERSION-arm
- docker push $HUB_REGISTRY_IMAGE:$SQUID_VERSION-arm
- docker tag $CONTAINER_BUILD_NOPROD_NAME_ARM $HUB_REGISTRY_IMAGE:latest-arm
- docker push $HUB_REGISTRY_IMAGE:latest-arm
variables:
GIT_STRATEGY: none
only:
- master
CHATGPT_API_KEY for OpenAi’s
API.chatgpt_analysis:
stage: Docs
image:
name: $CONTAINER_CLIENT_IMAGE
... <omitted for brevity>
script:
... <omitted for brevity>
- echo -e "$RESPONSE" > chatgpt_analysis_$(date +%Y%m%d).md
- mkdir -p ~/.ssh
- eval $(ssh-agent -s)
- '[[ -f /.dockerenv ]] && echo -e "Host *
StrictHostKeyChecking no
" > ~/.ssh/config'
- ssh-add <(echo "$SSH_NOSTROMO_KEY")
- pandoc -s --from=markdown+smart --to=html --metadata=encoding=UTF-8 -o chatgpt_analysis_$(date +%Y%m%d).html chatgpt_analysis_$(date +%Y%m%d).md
- scp -P 822 -r chatgpt_analysis*.html e2git@e2guardian.numsys.eu:/datas/e2/html/squid-ci/
update_dockerhub_readme:
image:
name: $CONTAINER_CLIENT_IMAGE
stage: Docs
before_script:
- apt update && apt install -y curl jq ca-certificates --no-upgrade --no-install-recommends --no-install-suggests
script:
...<omitted for brevity>
GIT_STRATEGY: A special GitLab CI/CD variable that
specifies Git strategy, set to ‘none’ in
push-docker-hub.CI: A variable set to ‘true’ during the execution of
dive job, as dive uses it.CHATGPT_API_KEY: The API key for OpenAI used in the
chatgpt_analysis job.CONTAINER_CLIENT_IMAGE: The base image used to create
the Docker image.DOCKER_HUB_USER and DOCKER_HUB_TOKEN:
Docker Hub username and access token used for authentication.GITLAB_TOKEN: GitLab access token used for Git
actions.SQUID_VERSION: The version of Squid retrieved from the
getsquid_vars job.variables.env: A file created in the
getsquid_vars job to store Squid’s version.Dockerfile: The Dockerfile path used in
hadolint job to lint.getsquid_vars: No dependencies.docker-hub-build: Depends on getsquid_vars
job to obtain Squid Version to tag Docker image.docker-hub-test: Depends on
docker-hub-build job to test Docker image.push-docker-hub: Depends on
docker-hub-test and getsquid_vars job to push
Docker image to Docker Hub.chatgpt_analysis: Depends on getsquid_vars
job. Gets the gitlab-ci config and the latest commit and OpenAI will
generate the MD explaining the jobs.update_dockerhub_readme: No dependencies. Reads
README.md and updates DockerHub description.getsquid_vars: outputs variables.env
having the obtained Squid version.docker-hub-build: builds and pushes Docker image to
Docker Hub.docker-hub-test: checks if Docker image sets up a local
squid proxy correctly.push-docker-hub: Pushes Docker image to Docker
Hub.chatgpt_analysis: outputs .md and
.html files explaining the jobs in the CI/CD pipeline.update_dockerhub_readme: updates Docker Hub
description.The commit message suggests that there is an update to the
README.md. This commit does not seem to have implications
on the execution of the pipeline since it concerns documentation. The
impacted file README.md is typically used for project
description, setup, and useful information related to the project. No
code or CI/CD pipeline definition is changed.
## Project: https://gitlab.com/fredbcode-images/squid