Create Docker Image
This page describes the rules that must be followed to create the docker image attached to the target repository.
Why a docker image ?
A Docker image is used to simplify deployment across host systems by packaging everything required to run the workflow into a single, consistent unit. It includes not only all necessary dependencies and software, but also the scripts themselves. This ensures that the execution environment is fully predefined, reproducible, and independent of the host configuration. As a result, there is no need to manually install or configure dependencies on each host, reducing setup complexity and eliminating environment-related inconsistencies.
Create the docker image
The docker image is build using the dockerfile located in the docker folder.
To allows the dAIEdge-VLab to clone the sources of the target repository the deployment token and the repository URL must be set in environment variables in the docker image. The following steps describe the mandatory environment variables that the docker image must have.
Install the minimum requirements
First, make sure the system you are using has docker installed. Use the docker official documentation to install docker.
Create the dockerfile
In the folder docker of the target repository, create a file named dockerfile. This file contains the instructions to build the docker image.
Modify the dockerfile by adding the following lines or use the dockerfile template :
FROM ubuntu:latest
RUN apt-get update
RUN apt-get install -y jq
WORKDIR /app
COPY ./ /app/Here install all the dependencies and software needed to run the scripts.
You must install jq in your image (is it???). Make sure that all the scripts and files of the repository are copied in the image. They must be located in the /app folder of the image as the dAIEdge-VLab will look for the scripts in this location.
So, for example, the support.sh script must be located in /app/AI_Support/support.sh in the docker image.
Build or push to the container registry manually
Start by logging in to the container registry with the following command :
docker login <your-registry-url> <your-registry-url> is the URL of the container registry. For gitlab.com, the URL is registry.gitlab.com. The credentials is the username and the token generated in the step Generate deploy token.
Then build the image with all the parameters :
docker build -t <your-registry-url>/<your-project-path>:latest . -f ./docker/dockerfileFinally, push the image to the container registry :
docker push <your-registry-url>/<your-project-path>:latestAutomate the process
It is recommended to automate the build and push of the docker image using a CI/CD pipeline. This allows to easily update the docker image when changes are made to the dockerfile or when dependencies are added. The following steps describe how to automate this process using GitLab CI/CD or GitHub Actions.
The CI/CD configuration must be placed in .gitlab-ci.yml at the root of the repository.
build-image:
image: docker:latest
stage: build-image
services:
- docker:dind
variables:
DOCKER_HOST: "tcp://docker:2375"
DOCKER_TLS_CERTDIR: ""
tags:
- your-runner-tag
script:
- docker login -u gitlab-ci-token -p $CI_JOB_TOKEN $CI_REGISTRY
- docker build -t $CI_REGISTRY_IMAGE:latest . -f ./docker/dockerfile
- docker push $CI_REGISTRY_IMAGE:latestGitLab provides built-in variables:
- CI_REGISTRY
- CI_REGISTRY_IMAGE
- CI_JOB_TOKEN
build-image doesn’t need to be modified and can simply be added to your CI/CD. All the values come from default CI/CD variables. However, you must change the your-runner-tag with the tag associated with the runner you want to use.Once your docker image is built and pushed to the container registry, you can move to the next step of the integration process : Container registry access.