Skip to content

add template konflux dockerfile#382

Open
weshayutin wants to merge 1 commit intoopenshift:oadp-devfrom
weshayutin:konflux-oadpdev
Open

add template konflux dockerfile#382
weshayutin wants to merge 1 commit intoopenshift:oadp-devfrom
weshayutin:konflux-oadpdev

Conversation

@weshayutin
Copy link
Contributor

No description provided.

Signed-off-by: Wesley Hayutin <weshayutin@gmail.com>
@coderabbitai
Copy link

coderabbitai bot commented Mar 17, 2026

Walkthrough

A new multi-stage Dockerfile (konflux.Dockerfile) introduced for building an OpenShift Velero plugin. The builder stage compiles the Go application with static linking, while the runtime stage packages it into a UBI-based image with non-root execution configured.

Changes

Cohort / File(s) Summary
Multi-stage Build Configuration
konflux.Dockerfile
New 26-line multi-stage Dockerfile with builder stage compiling Go binary and runtime stage creating minimal OCI image with non-root user, entrypoint for plugin installation, and necessary labels.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
📝 Coding Plan
  • Generate coding plan for human review comments

Comment @coderabbitai help to get the list of available commands and usage tips.

@openshift-ci
Copy link

openshift-ci bot commented Mar 17, 2026

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: weshayutin
Once this PR has been reviewed and has the lgtm label, please assign rayfordj for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 3

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@konflux.Dockerfile`:
- Line 14: Replace the floating base image tag in the Dockerfile FROM
instruction (currently "registry.redhat.io/ubi9/ubi:latest") with a specific,
reproducible version tag (for example "registry.redhat.io/ubi9/ubi:9.3" or your
project's approved UBI9 patch version); update the FROM line accordingly and
ensure any CI/build docs or image scanning policy reflect the chosen fixed tag.
- Around line 2-5: The Dockerfile currently copies the whole context early (COPY
. .) which defeats layer caching and duplicates source copies; reorder and
simplify so you first COPY go.mod go.sum to the destination referenced in the
diff (the path used with COPY go.mod go.sum
$APP_ROOT/src/github.com/konveyor/openshift-velero-plugin/), run RUN go mod
download to populate module cache, then COPY the remaining source once (replace
the initial COPY . . and the later COPY . ...) so dependency layers are cached
and source is only copied once.
- Line 17: The COPY --from=builder line fails because $APP_ROOT and $BIN are
only defined in the builder stage; declare those build args or envs so they are
available in the runtime stage (or replace with a static path). Add ARG APP_ROOT
and ARG BIN (or ENV definitions) in a scope visible to both stages (e.g., before
the first FROM or re-declare them in the runtime stage) so the COPY
--from=builder $APP_ROOT/src/.../$BIN /plugins/ resolves correctly at build
time.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 15e31f32-56de-4dc8-8d3e-81a3a3ae6364

📥 Commits

Reviewing files that changed from the base of the PR and between d00ee21 and e226607.

📒 Files selected for processing (1)
  • konflux.Dockerfile

Comment on lines +2 to +5
COPY . .
COPY go.mod go.sum $APP_ROOT/src/github.com/konveyor/openshift-velero-plugin/
RUN go mod download
COPY . $APP_ROOT/src/github.com/konveyor/openshift-velero-plugin
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

Dependency layer caching is currently defeated.

COPY . . before go mod download causes dependency downloads to rerun on any source change, and the full source is copied twice.

Proposed fix
-FROM brew.registry.redhat.io/rh-osbs/openshift-golang-builder:rhel_9_golang_1.25 AS builder
-COPY . .
-COPY go.mod go.sum $APP_ROOT/src/github.com/konveyor/openshift-velero-plugin/
-RUN go mod download
-COPY . $APP_ROOT/src/github.com/konveyor/openshift-velero-plugin
-WORKDIR $APP_ROOT/src/github.com/konveyor/openshift-velero-plugin
+FROM brew.registry.redhat.io/rh-osbs/openshift-golang-builder:rhel_9_golang_1.25 AS builder
+WORKDIR $APP_ROOT/src/github.com/konveyor/openshift-velero-plugin
+COPY go.mod go.sum ./
+RUN go mod download
+COPY . ./

As per coding guidelines, "Focus on major issues impacting performance, readability, maintainability and security. Avoid nitpicks and avoid verbosity."

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@konflux.Dockerfile` around lines 2 - 5, The Dockerfile currently copies the
whole context early (COPY . .) which defeats layer caching and duplicates source
copies; reorder and simplify so you first COPY go.mod go.sum to the destination
referenced in the diff (the path used with COPY go.mod go.sum
$APP_ROOT/src/github.com/konveyor/openshift-velero-plugin/), run RUN go mod
download to populate module cache, then COPY the remaining source once (replace
the initial COPY . . and the later COPY . ...) so dependency layers are cached
and source is only copied once.

RUN go build -installsuffix "static" -tags "$BUILDTAGS" -mod=mod -o _output/$BIN ./$BIN


FROM registry.redhat.io/ubi9/ubi:latest
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail
# Verify whether floating base tags are present in Dockerfiles.
rg -n '^\s*FROM\s+\S+:latest(\s|$)' --glob '*Dockerfile*'

Repository: openshift/openshift-velero-plugin

Length of output: 138


Use explicit version tags instead of latest for the base image.

Floating tags like ubi:latest prevent reproducible builds and can introduce unexpected base-image changes without review. Pin to a specific version (e.g., ubi9/ubi:9.3 or similar).

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@konflux.Dockerfile` at line 14, Replace the floating base image tag in the
Dockerfile FROM instruction (currently "registry.redhat.io/ubi9/ubi:latest")
with a specific, reproducible version tag (for example
"registry.redhat.io/ubi9/ubi:9.3" or your project's approved UBI9 patch
version); update the FROM line accordingly and ensure any CI/build docs or image
scanning policy reflect the chosen fixed tag.

FROM registry.redhat.io/ubi9/ubi:latest
RUN dnf -y install openssl && dnf -y reinstall tzdata && dnf clean all
RUN mkdir /plugins
COPY --from=builder $APP_ROOT/src/github.com/konveyor/openshift-velero-plugin/_output/$BIN /plugins/
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail
# Show variable usage and stage-local declarations around runtime stage.
nl -ba konflux.Dockerfile | sed -n '1,26p'
echo
echo "Runtime-stage ENV/ARG declarations:"
awk '
  BEGIN {stage=0}
  /^\s*FROM\s+/ {stage++; next}
  stage==2 && /^\s*(ENV|ARG)\s+/ {print NR ":" $0}
' konflux.Dockerfile
echo
echo "Variable references in COPY --from lines:"
rg -n '^\s*COPY\s+--from=.*\$(APP_ROOT|BIN)' konflux.Dockerfile

Repository: openshift/openshift-velero-plugin

Length of output: 119


🏁 Script executed:

#!/bin/bash
# Read the Dockerfile to understand its structure and variable usage
cat -n konflux.Dockerfile

Repository: openshift/openshift-velero-plugin

Length of output: 1581


COPY --from=builder references variables undefined in runtime stage.

$APP_ROOT and $BIN are only available in the builder stage. In the runtime stage (line 14 onwards), Dockerfile expands these variables in the current stage context where they're undefined, causing the COPY on line 17 to fail or copy from an incorrect path.

Add the following to the runtime stage:

 FROM registry.redhat.io/ubi9/ubi:latest
+ENV APP_ROOT=/opt/app-root
+ENV BIN=velero-plugins
 RUN dnf -y install openssl && dnf -y reinstall tzdata && dnf clean all
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@konflux.Dockerfile` at line 17, The COPY --from=builder line fails because
$APP_ROOT and $BIN are only defined in the builder stage; declare those build
args or envs so they are available in the runtime stage (or replace with a
static path). Add ARG APP_ROOT and ARG BIN (or ENV definitions) in a scope
visible to both stages (e.g., before the first FROM or re-declare them in the
runtime stage) so the COPY --from=builder $APP_ROOT/src/.../$BIN /plugins/
resolves correctly at build time.

@openshift-ci
Copy link

openshift-ci bot commented Mar 17, 2026

@weshayutin: all tests passed!

Full PR test history. Your PR dashboard.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant