Skip to main content
Redhat Developers  Logo
  • Products

    Platforms

    • Red Hat Enterprise Linux
      Red Hat Enterprise Linux Icon
    • Red Hat AI
      Red Hat AI
    • Red Hat OpenShift
      Openshift icon
    • Red Hat Ansible Automation Platform
      Ansible icon
    • See all Red Hat products

    Featured

    • Red Hat build of OpenJDK
    • Red Hat Developer Hub
    • Red Hat JBoss Enterprise Application Platform
    • Red Hat OpenShift Dev Spaces
    • Red Hat OpenShift Local
    • Red Hat Developer Sandbox

      Try Red Hat products and technologies without setup or configuration fees for 30 days with this shared Red Hat OpenShift and Kubernetes cluster.
    • Try at no cost
  • Technologies

    Featured

    • AI/ML
      AI/ML Icon
    • Linux
      Linux Icon
    • Kubernetes
      Cloud icon
    • Automation
      Automation Icon showing arrows moving in a circle around a gear
    • See all technologies
    • Programming languages & frameworks

      • Java
      • Python
      • JavaScript
    • System design & architecture

      • Red Hat architecture and design patterns
      • Microservices
      • Event-Driven Architecture
      • Databases
    • Developer experience

      • Productivity
      • Tools
      • GitOps
    • Automated data processing

      • AI/ML
      • Data science
      • Apache Kafka on Kubernetes
    • Platform engineering

      • DevOps
      • DevSecOps
      • Red Hat Ansible Automation Platform for applications and services
    • Secure development & architectures

      • Security
      • Secure coding
  • Learn

    Featured

    • Kubernetes & cloud native
      Openshift icon
    • Linux
      Rhel icon
    • Automation
      Ansible cloud icon
    • AI/ML
      AI/ML Icon
    • See all learning resources

    E-books

    • GitOps cookbook
    • Podman in action
    • Kubernetes operators
    • The path to GitOps
    • See all e-books

    Cheat sheets

    • Linux commands
    • Bash commands
    • Git
    • systemd commands
    • See all cheat sheets

    Documentation

    • Product documentation
    • API catalog
    • Legacy documentation
  • Developer Sandbox

    Developer Sandbox

    • Access Red Hat’s products and technologies without setup or configuration, and start developing quicker than ever before with our new, no-cost sandbox environments.
    • Explore the Developer Sandbox

    Featured Developer Sandbox activities

    • Get started with your Developer Sandbox
    • OpenShift virtualization and application modernization using the Developer Sandbox
    • Explore all Developer Sandbox activities

    Ready to start developing apps?

    • Try at no cost
  • Blog
  • Events
  • Videos

How to build an image mode pipeline with GitLab

Automated OS deployment

February 12, 2026
Preethi Thomas Chris Kyrouac
Related topics:
Automation and managementCI/CDContainersLinux
Related products:
Image mode for Red Hat Enterprise LinuxRed Hat Enterprise Linux

    This guide provides a step-by-step process for creating a robust, automated CI/CD pipeline for image mode for Red Hat Enterprise Linux (RHEL) using GitLab. Image mode, utilizing the power of bootc (bootable containers), fundamentally shifts how we manage and deploy operating systems. Instead of traditional package management, we treat the OS as a container image, making deployments immutable, verifiable, and highly consistent.

    Set up the pipeline

    Before setting up the pipeline, ensure you have the following prerequisites:

    1. GitLab project: You must have a repository containing your image mode configuration. For the purpose of this example, include a Containerfile and an example systemd service. This is the layout of the project:
    ├── Containerfile
    └── etc
        └── systemd
            └── system
                └── my-app.service
    1. my-app.service: This is a simple custom systemd service.
    [Unit]
    Description=My app
    [Service]
    Type=oneshot
    ExecStart=/usr/sbin/echo "My app"
    [Install]
    WantedBy=default.target
    1. Containerfile: This file defines your image mode base image and any custom packages or configurations.
    # Example starting point (adjust version as necessary)
    FROM registry.redhat.io/rhel10/rhel-bootc@sha256:3cf9522137f3b643a780d303ee6a823cc04df847c24a4103d5563cd44785df04
    # Copy the systemd service into the bootc image
    COPY etc etc
    # Install custom packages
    RUN <<EOF
        set -euxo pipefail
        dnf install -y cockpit-ws httpd
        dnf clean all
    EOF
    1. GitLab variables: Securely store your Red Hat container registry credentials (e.g., CI_REGISTRY_USER, CI_REGISTRY_PASSWORD) and subscription secrets (RH_USER, RH_PASSWORD) as GitLab CI/CD variables.

    The image mode CI/CD pipeline flow process involves three primary stages: build, package, and deploy.

    Stage 1: Dependency management

    While not strictly a CI job, automatic dependency management is crucial for maintaining an up-to-date and secure base OS image. The goal is to use a dependency bot (i.e., Renovate Bot or Dependabot) to automatically detect new versions of the parent image (registry.redhat.io/rhel10/rhel-bootc:10.1).

    The key concept is to guarantee reproducible builds and enhanced security. You should reference your parent image using both a static tag and its content digest (SHA256). The bot will automatically update the digest in a merge request when the underlying image content changes.

    Stage 2: Building and pushing the bootc container image

    This is the first true CI stage, where the Containerfile is executed to produce the final, bootable container image. Use this container image to create the installation disk and to upgrade existing systems. Create .gitlab-ci.yml in the root of your project with the following contents.

    Tools: Podman or Buildah are ideal for this stage. They are often available in standard GitLab runners, or you can run them within a specialized runner image.

    GitLab CI job (.gitlab-ci.yml):

    stages:
      - build
      - package
      - deploy
    # Use semantic versioning for release tags (e.g., 1.0.0)
    variables:
      IMAGE_NAME: $CI_REGISTRY_IMAGE/my-rhel-os
      IMAGE_TAG: $CI_COMMIT_SHORT_SHA
    build_bootc_image:
      stage: build
      image: registry.access.redhat.com/ubi10/podman:latest
      script:
        - |
          set -euxo pipefail
          # Login to the gitlab registry where this image will be pushed to
          podman login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
          # Login to registry.redhat.com so we can pull the rhel-bootc image
          podman login -u $RH_REGISTRY_USER -p $RH_REGISTRY_PASSWORD registry.redhat.io
          subscription-manager register --username $RHN_USER --password $RHN_PASSWORD
          # Set up entitlement secrets for podman build
          # Podman expects these at /run/secrets/ per /etc/containers/mounts.conf
          # This is a hack to enable rhsm for demonstration purposes
          # In a production environment the runner should be registered with RHSM.
          mkdir -p /run/secrets/etc-pki-entitlement
          cp /etc/pki/entitlement/*.pem /run/secrets/etc-pki-entitlement/
          mkdir -p /run/secrets/rhsm
          cp -r /etc/rhsm/* /run/secrets/rhsm/
          podman build -t $IMAGE_NAME:$IMAGE_TAG .
          podman push $IMAGE_NAME:$IMAGE_TAG

    Stage 3: Packaging the disk image (OS artifact)

    The bootc image is not directly deployable to bare metal or VMs. You must convert it into a disk image format (e.g., .qcow2, .ami, .vmdk). This is where the bootc-image-builder (BIB) tool comes in. Update .gitlab-ci.yml with a new build_disk_image job.

    Tools: Run the bootc-image-builder as a container, making it easy to integrate.

    GitLab CI job (.gitlab-ci.yml):

    # Convert the bootc image to a disk image (qcow2 example)
    build_disk_image:
      stage: package
      tags:
        - saas-linux-large-amd64
      image:
        name: quay.io/centos-bootc/bootc-image-builder:latest
        entrypoint: [""]
      needs:
        - build_bootc_image
      script:
        - |
          set -euxo pipefail
          mkdir output
          podman login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
          podman pull $IMAGE_NAME:$IMAGE_TAG
          bootc-image-builder $IMAGE_NAME:$IMAGE_TAG --type qcow2 --output ./output
      artifacts:
        paths:
          - output/*.qcow2

    Note: The bootc-image-builder requires --privileged mode to handle the necessary disk partitioning and filesystem creation, so your runner must support this. The shared instance runners on Gitlab are not supported, so you will need a custom runner for this step.

    Stage 4: Deployment and storage

    The final stage pushes the compiled OS artifact (.qcow2 file) to an accessible location, typically an object storage service like Amazon S3, Azure Blob Storage, or a private server.

    Tools: Use cloud provider CLIs (e.g., AWS or AZ) or standard Linux tools (curl, rsync) depending on your target.

    GitLab CI job (.gitlab-ci.yml):

    # Upload the disk image to object storage for deployment
    deploy_image_artifact:
      stage: deploy
      image: python:latest # Use a common image that can install cloud CLIs
      needs:
        - build_disk_image
      script:
        - echo "--- Installing AWS CLI (Example) ---"
        - pip install awscli
        # Ensure AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY are set as CI variables
        
        - echo "--- Uploading qcow2 file to S3 ---"
        - FILE_PATH=$(find output -name "*.qcow2")
        - aws s3 cp $FILE_PATH s3://your-os-artifacts-bucket/rhel-image-mode/$IMAGE_TAG.qcow2
        
        - echo "Deployment artifact available at: s3://your-os-artifacts-bucket/rhel-image-mode/$IMAGE_TAG.qcow2"
      # Only run this job when pushing to the main branch
      only:
        - main 

    Wrap up

    By structuring your GitLab CI/CD pipeline around the three stages—building the bootc container, packaging the disk image using bootc-image-builder, and deploying the artifact—you can fully automate your image mode operating system updates. You can easily provision new systems with the disk image and update existing systems with the new container image. This approach guarantees consistency, leverages container security features, and dramatically speeds up your OS deployment and patching cycles.

    Related Posts

    • Image mode for RHEL 10: Updates in seconds with soft reboot

    • Customize RHEL CoreOS at scale: On-cluster image mode in OpenShift

    • How to deploy an image mode update in offline and air-gapped environments

    • How to embed containers on image mode for RHEL

    Recent Posts

    • How to build an image mode pipeline with GitLab

    • Build a zero trust environment with Red Hat Connectivity Link

    • Guide to configuring multiple authentication providers in Developer Hub

    • Agentic AI: Design reliable workflows across the hybrid cloud

    • Camel JBang in Motion: Two New Hands-on Labs for Fast-Paced Learning

    What’s up next?

    Learning Path Install_image_mode_for RHEL_kickstart feature image

    Install image mode for Red Hat Enterprise Linux using Kickstart

    Deploy image mode for Red Hat Enterprise Linux step-by-step using Kickstart,...
    Red Hat Developers logo LinkedIn YouTube Twitter Facebook

    Platforms

    • Red Hat AI
    • Red Hat Enterprise Linux
    • Red Hat OpenShift
    • Red Hat Ansible Automation Platform
    • See all products

    Build

    • Developer Sandbox
    • Developer tools
    • Interactive tutorials
    • API catalog

    Quicklinks

    • Learning resources
    • E-books
    • Cheat sheets
    • Blog
    • Events
    • Newsletter

    Communicate

    • About us
    • Contact sales
    • Find a partner
    • Report a website issue
    • Site status dashboard
    • Report a security problem

    RED HAT DEVELOPER

    Build here. Go anywhere.

    We serve the builders. The problem solvers who create careers with code.

    Join us if you’re a developer, software engineer, web designer, front-end designer, UX designer, computer scientist, architect, tester, product manager, project manager or team lead.

    Sign me up

    Red Hat legal and privacy links

    • About Red Hat
    • Jobs
    • Events
    • Locations
    • Contact Red Hat
    • Red Hat Blog
    • Inclusion at Red Hat
    • Cool Stuff Store
    • Red Hat Summit
    © 2025 Red Hat

    Red Hat legal and privacy links

    • Privacy statement
    • Terms of use
    • All policies and guidelines
    • Digital accessibility

    Report a website issue