Skip to content

CherryPicked: [v2.10] build: standardize container image - #376

Merged
myakove merged 1 commit into
v2.10from
CherryPicked-container-image-improvements-Dkm78
Mar 24, 2026
Merged

myakove merged 1 commit into
v2.10from
CherryPicked-container-image-improvements-Dkm78

Conversation

@myakove

@myakove myakove commented Mar 24, 2026

Copy link
Copy Markdown
Collaborator

Cherry-pick from main branch, original PR: #371, PR owner: rgolangh

* Standardize container image

- Base the image on UBI 10.1
- Make the container image able to run with user 1001 so special security
  context change. Standard /app directory structure
- Lock the uv version for reproducible builds
- Ignore python caches

Signed-off-by: Roy Golan <rgolan@redhat.com>

* fix: pin UBI base image by digest and use explicit pip invocation

- Pin ubi-minimal:10.1 by sha256 digest for reproducible builds
- Use python3 -m pip instead of bare pip for explicit interpreter binding
- Remove redundant UV_CACHE_DIR (UV_NO_CACHE=1 already disables caching)
- Remove unnecessary cache cleanup step

* docs: add non-root container guidance for bind-mount permissions

Document that the container runs as UID 1001 and provide guidance
for writable bind mounts across podman rootless, rootful, and OpenShift.

* fix: add --no-run-if-empty flag to xargs in Dockerfile

Prevents build failure when no __pycache__ directories exist,
which is more likely with PYTHONDONTWRITEBYTECODE=1 set.

* fix: install uv via COPY --from instead of pip

Use COPY --from=ghcr.io/astral-sh/uv:latest for cleaner uv installation.
Drop python3-pip dependency since pip is no longer needed.

---------

Signed-off-by: Roy Golan <rgolan@redhat.com>
@qodo-code-review

Copy link
Copy Markdown
ⓘ You are approaching your monthly quota for Qodo. Upgrade your plan

Review Summary by Qodo

Standardize container image with UBI base and non-root execution

✨ Enhancement

Grey Divider

Walkthroughs

Description
• Migrate base image from Fedora 41 to UBI 10.1 with digest pinning
• Enable non-root container execution with UID 1001 and group permissions
• Optimize Python caching and build reproducibility with uv and environment variables
• Install uv via COPY --from instead of pip for cleaner dependency management
• Add comprehensive documentation for bind-mount permissions across platforms
Diagram
flowchart LR
  A["Fedora 41 Base Image"] -->|"Replace with"| B["UBI 10.1 by Digest"]
  C["Root User"] -->|"Switch to"| D["UID 1001 Non-root"]
  E["dnf Package Manager"] -->|"Replace with"| F["microdnf"]
  G["pip uv Installation"] -->|"Replace with"| H["COPY --from uv"]
  I["Python Cache Enabled"] -->|"Disable with"| J["PYTHONDONTWRITEBYTECODE"]
  K["Manual Cache Cleanup"] -->|"Simplify with"| L["UV_NO_CACHE=1"]
Loading

Grey Divider

File Changes

1. Dockerfile ✨ Enhancement +21/-16

Standardize container with UBI, non-root user, and uv installation

• Changed base image from Fedora 41 to UBI 10.1 pinned by SHA256 digest for reproducibility
• Replaced dnf with microdnf and simplified package manager cleanup
• Added environment variables for Python caching control and output buffering
• Installed uv via COPY --from instead of pip, removing python3-pip dependency
• Added group permission changes and switched to non-root USER 1001
• Added --no-run-if-empty flag to xargs to prevent build failures with empty __pycache__
• Reorganized COPY commands and moved uv installation before WORKDIR setup

Dockerfile


2. README.md 📝 Documentation +8/-0

Document non-root container and bind-mount permission guidance

• Added guidance for non-root container (UID 1001) and bind-mount permissions
• Documented platform-specific solutions for podman rootless, rootful, and OpenShift
• Clarified that read-only mounts are unaffected by non-root execution
• Added note about automatic group-permission handling in OpenShift

README.md


Grey Divider

Qodo Logo

@qodo-code-review

qodo-code-review Bot commented Mar 24, 2026 •

Copy link
Copy Markdown

Code Review by Qodo

🐞 Bugs (1) 📘 Rule violations (0) 📎 Requirement gaps (0) 📐 Spec deviations (0)

Grey Divider


Action required

1. Missing bash in image 🐞 Bug ✓ Correctness
Description
The container is now based on UBI minimal and does not install bash, but the README and
copyoffload docs run the image with /bin/bash -c, which will fail at runtime with “/bin/bash: no
such file or directory”. This breaks the primary documented OpenShift Job execution path.
Code

Dockerfile[R18-27]

+RUN microdnf -y install \
  libxml2-devel \
  libcurl-devel \
  openssl \
  openssl-devel \
-  libcurl-devel \
  gcc \
  clang \
+  git \
  python3-devel \
-  && dnf clean all \
-  && rm -rf /var/cache/dnf \
-  && rm -rf /var/lib/dnf \
-  && truncate -s0 /var/log/*.log && rm -rf /var/cache/yum
+  && microdnf clean all
Evidence
The Dockerfile installs several build dependencies with microdnf but does not install bash (or
otherwise guarantee /bin/bash exists). Meanwhile, the OpenShift Job templates in both README and
docs explicitly set the container command to /bin/bash -c, so those Jobs will fail to start when
using this image.

Dockerfile[18-27]
README.md[357-361]
docs/copyoffload/how-to-run-copyoffload-tests.md[315-320]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
The container image no longer guarantees `/bin/bash` exists (UBI minimal), but docs/Job templates run `/bin/bash -c ...`, causing runtime failures.

## Issue Context
The Dockerfile installs dependencies via `microdnf` but omits `bash`. Multiple documented OpenShift Job templates use `/bin/bash` as the entry command.

## Fix Focus Areas
- Dockerfile[18-27]
- README.md[357-360]
- docs/copyoffload/how-to-run-copyoffload-tests.md[315-318]

## Recommended fix
Choose one:
1) Add `bash` to the `microdnf install` list (preferred if you want to keep Job templates unchanged).
2) Update docs/templates to use `/bin/sh -c` instead of `/bin/bash -c` (only if UBI minimal guarantees `/bin/sh`), and ensure any bash-specific syntax is not used.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


Grey Divider

ⓘ The new review experience is currently in Beta. Learn more

Grey Divider

Qodo Logo

@rh-bot-1

Copy link
Copy Markdown

Report bugs in Issues

Welcome! 🎉

This pull request will be automatically processed with the following features:

🔄 Automatic Actions

  • Reviewer Assignment: Reviewers are automatically assigned based on the OWNERS file in the repository root
  • Size Labeling: PR size labels (XS, S, M, L, XL, XXL) are automatically applied based on changes
  • Issue Creation: Disabled for this repository
  • Branch Labeling: Branch-specific labels are applied to track the target branch
  • Auto-verification: Auto-verified users have their PRs automatically marked as verified
  • Labels: All label categories are enabled (default configuration)

📋 Available Commands

PR Status Management

  • /wip - Mark PR as work in progress (adds WIP: prefix to title)
  • /wip cancel - Remove work in progress status
  • /hold - Block PR merging (approvers only)
  • /hold cancel - Unblock PR merging
  • /verified - Mark PR as verified
  • /verified cancel - Remove verification status
  • /reprocess - Trigger complete PR workflow reprocessing (useful if webhook failed or configuration changed)
  • /regenerate-welcome - Regenerate this welcome message

Review & Approval

  • /lgtm - Approve changes (looks good to me)
  • /approve - Approve PR (approvers only)
  • /automerge - Enable automatic merging when all requirements are met (maintainers and approvers only)
  • /assign-reviewers - Assign reviewers based on OWNERS file
  • /assign-reviewer @username - Assign specific reviewer
  • /check-can-merge - Check if PR meets merge requirements

Testing & Validation

  • /retest tox - Run Python test suite with tox
  • /retest build-container - Rebuild and test container image
  • /retest conventional-title - Validate commit message format
  • /retest all - Run all available tests

Container Operations

  • /build-and-push-container - Build and push container image (tagged with PR number)
    • Supports additional build arguments: /build-and-push-container --build-arg KEY=value

Cherry-pick Operations

  • /cherry-pick <branch> - Schedule cherry-pick to target branch when PR is merged
    • Multiple branches: /cherry-pick branch1 branch2 branch3

Label Management

  • /<label-name> - Add a label to the PR
  • /<label-name> cancel - Remove a label from the PR

✅ Merge Requirements

This PR will be automatically approved when the following conditions are met:

  1. Approval: /approve from at least one approver
  2. Status Checks: All required status checks must pass
  3. No Blockers: No wip, hold, has-conflicts labels and PR must be mergeable (no conflicts)
  4. Verified: PR must be marked as verified

📊 Review Process

Approvers and Reviewers

Approvers:

  • myakove
  • solenoci

Reviewers:

  • krcmarik
  • myakove
  • solenoci
Available Labels
  • hold
  • verified
  • wip
  • lgtm
  • approve
  • automerge

💡 Tips

  • WIP Status: Use /wip when your PR is not ready for review
  • Verification: The verified label is automatically removed on each new commit
  • Cherry-picking: Cherry-pick labels are processed when the PR is merged
  • Container Builds: Container images are automatically tagged with the PR number
  • Permission Levels: Some commands require approver permissions
  • Auto-verified Users: Certain users have automatic verification and merge privileges

For more information, please refer to the project documentation or contact the maintainers.

@myakove

myakove commented Mar 24, 2026

Copy link
Copy Markdown
Collaborator Author

/lgtm
/approve
/verified

@myakove
myakove merged commit 952df34 into v2.10 Mar 24, 2026
7 checks passed
@myakove
myakove deleted the CherryPicked-container-image-improvements-Dkm78 branch March 24, 2026 15:43
@rh-bot-1

Copy link
Copy Markdown

New container for ghcr.io/redhatqe/mtv-api-tests:v2.10 published

Comment thread Dockerfile
Comment on lines +18 to +27
RUN microdnf -y install \
libxml2-devel \
libcurl-devel \
openssl \
openssl-devel \
libcurl-devel \
gcc \
clang \
git \
python3-devel \
&& dnf clean all \
&& rm -rf /var/cache/dnf \
&& rm -rf /var/lib/dnf \
&& truncate -s0 /var/log/*.log && rm -rf /var/cache/yum
&& microdnf clean all

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Action required

1. Missing bash in image 🐞 Bug ✓ Correctness

The container is now based on UBI minimal and does not install bash, but the README and
copyoffload docs run the image with /bin/bash -c, which will fail at runtime with “/bin/bash: no
such file or directory”. This breaks the primary documented OpenShift Job execution path.
Agent Prompt
## Issue description
The container image no longer guarantees `/bin/bash` exists (UBI minimal), but docs/Job templates run `/bin/bash -c ...`, causing runtime failures.

## Issue Context
The Dockerfile installs dependencies via `microdnf` but omits `bash`. Multiple documented OpenShift Job templates use `/bin/bash` as the entry command.

## Fix Focus Areas
- Dockerfile[18-27]
- README.md[357-360]
- docs/copyoffload/how-to-run-copyoffload-tests.md[315-318]

## Recommended fix
Choose one:
1) Add `bash` to the `microdnf install` list (preferred if you want to keep Job templates unchanged).
2) Update docs/templates to use `/bin/sh -c` instead of `/bin/bash -c` (only if UBI minimal guarantees `/bin/sh`), and ensure any bash-specific syntax is not used.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants