Additional details on the build process.
: Deniz Aydin
Minutes: 10
I’m adding details on what to modify in case the build needs to be reconfigured.
- If the dependencies change, you need to do a
pip freeze
and pipe the output to a file calledrequirements.txt
that lives on in the project root directory. - The Dockerfile commands need to be updated for additional installations required for the build process. As is, it runs well with a base image of
ubuntu:noble
, which is stable. I then add all the relevant programs needed to this ubuntu image. Examples of relevant programs might bepython3, ant, openjdk, ant-contrib
and other things I’m installing with apt-get. Note that there is a need to use a virtual environment, which I am creating atopt/venv
. Installing the dependencies system-wide will not work, as per the new security rules of the newer python distros. - After the Dockerfile is completed, you need to run the following commands to build a Docker image:
docker build --no-cache -t dni-git-agnostic .
The docker build command takes a -t argument (tag name, which in this case isdni-git-agnostic
) and a --no-cache argument which means that everything will be built anew. You may choose to use the cached fragments and omit this tag depending on your application.docker tag dni-git-agnostic daydzs/dni-git-agnostic:latest
can be used for re-tagging the image.docker images
will display all the current Docker images. Grab the ID belonging todni-git-agnostic
now.docker run -d -p 8000:8000 [INSERT_YOUR_ID]
to run the container you’ve just produced with the ID you obtained from the previous step.docker push daydzs/dni-git-agnostic:latest
pushes the last image you’ve created with the given name. Now, your Docker container lives in your repository in Docker Hub. For the purposes of this exercise, mine lives on in my repository titleddaydzs
.
- GitLab YAML file needs to be updated to point to this Docker image you have just created. Update every instance of
image: [PREVIOUS_IMAGE_NAME]
toimage: daydzs/dni-git-agnostic:latest
. This will now mean that when we trigger the pipeline, this new Docker image will be used. - Note that BOTH the Docker Daemon and a gitlab-runner that is registered for this project NEED to be running for the pipeline to work. The Docker Daemon needs to start the dnigit server, and the Gitlab runner, which is currently registered on Spartan, need to be running.