CI Github - Open-Quantum-Platform/openqp GitHub Wiki
To create or update the Docker image used in CI, follow these steps:
-
Install Docker: Ensure Docker is installed on your computer. You can find installation instructions here.
-
Set Up Your Workspace:
- Create a new empty directory and navigate to it in your terminal.
- Inside this directory, create a file named
Dockerfile
and populate it with the relevant commands.
-
Log In to GitHub Container Registry:
- Authenticate with GitHub Container Registry by running:
Replace
echo $CR_PAT | docker login ghcr.io -u USERNAME --password-stdin
CR_PAT
with your GitHub Personal Access Token andUSERNAME
with your GitHub username. More information on generating a token can be found here.
- Authenticate with GitHub Container Registry by running:
-
(Optional) Update the Ubuntu Image:
- If necessary, update the base Ubuntu image on your computer using
docker pull <image>
, where<image>
could beubuntu:20.04
.
- If necessary, update the base Ubuntu image on your computer using
-
Build the Docker Image:
- Run the following command to build the Docker image:
Replace
docker build -t ghcr.io/USERNAME/oqp-ci-ubuntu:<version> .
USERNAME
with your GitHub username and<version>
with a descriptive tag, such as2024.8
. The dot at the end indicates the current directory (where the Dockerfile is located).
- Run the following command to build the Docker image:
-
Tag the Image as
latest
:- If the build succeeds, tag the image as
latest
:docker tag ghcr.io/USERNAME/oqp-ci-ubuntu:<version> ghcr.io/USERNAME/oqp-ci-ubuntu:latest
- Alternatively, you can use the image ID instead of
old_tag
, which can be found withdocker image ls
.
- If the build succeeds, tag the image as
-
Push the Image to GitHub Container Registry:
- Push your versioned image to the registry:
docker push ghcr.io/USERNAME/oqp-ci-ubuntu:<version>
- To test the new image, you can update the CI configuration file (e.g.,
.github/workflows/ci.yml
) in your branch to use your specific version.
- Push your versioned image to the registry:
-
Finalize the Image:
- If everything works as expected, push the
latest
tag to the registry:docker push ghcr.io/USERNAME/oqp-ci-ubuntu:latest
- This will make the image the default for all branches during CI. Don’t forget to revert any changes you made to the CI configuration file in your branch.
- If everything works as expected, push the
By following these steps, you can effectively manage and update the Docker images used in the OQP CI pipeline on GitHub, ensuring that all necessary software and tools are available for building and running the platform.