CI Github - Open-Quantum-Platform/openqp GitHub Wiki

Creating/Updating the Docker Image for GitHub

To create or update the Docker image used in CI, follow these steps:

  1. Install Docker: Ensure Docker is installed on your computer. You can find installation instructions here.

  2. 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.
  3. Log In to GitHub Container Registry:

    • Authenticate with GitHub Container Registry by running:
      echo $CR_PAT | docker login ghcr.io -u USERNAME --password-stdin
      Replace CR_PAT with your GitHub Personal Access Token and USERNAME with your GitHub username. More information on generating a token can be found here.
  4. (Optional) Update the Ubuntu Image:

    • If necessary, update the base Ubuntu image on your computer using docker pull <image>, where <image> could be ubuntu:20.04.
  5. Build the Docker Image:

    • Run the following command to build the Docker image:
      docker build -t ghcr.io/USERNAME/oqp-ci-ubuntu:<version> .
      Replace USERNAME with your GitHub username and <version> with a descriptive tag, such as 2024.8. The dot at the end indicates the current directory (where the Dockerfile is located).
  6. 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 with docker image ls.
  7. 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.
  8. 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.

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.

Going back to Administration Documentation

⚠️ **GitHub.com Fallback** ⚠️