From acd067ac567c0212dea6116825b37f0e001bd83f Mon Sep 17 00:00:00 2001 From: M Sajid Mansoori Date: Thu, 14 May 2026 14:09:57 +0530 Subject: [PATCH 1/6] Initial dockerfile for konflux Signed-off-by: M Sajid Mansoori --- konflux.Dockerfile | 54 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 konflux.Dockerfile diff --git a/konflux.Dockerfile b/konflux.Dockerfile new file mode 100644 index 00000000..bd48be51 --- /dev/null +++ b/konflux.Dockerfile @@ -0,0 +1,54 @@ +FROM registry.redhat.io/ubi9/go-toolset:1.25 AS builder + +COPY . /workspace +WORKDIR /workspace + +ARG BUILD_VERSION=v0.0.0 +ARG SOURCE_GIT_COMMIT=unknown +ARG TARGETOS=linux +ARG TARGETARCH=amd64 + +RUN set -e && \ + MTA_OPS_VERSION="${BUILD_VERSION:-dev}" && \ + mkdir -p /tmp/archives /tmp/bin && \ + for platform in linux/amd64 linux/arm64 darwin/amd64 darwin/arm64 windows/amd64 windows/arm64; do \ + os=$(echo "$platform" | cut -d'/' -f1) && \ + arch=$(echo "$platform" | cut -d'/' -f2) && \ + if [ "$os" = "windows" ]; then \ + output="mta-ops_${os}_${arch}.exe"; \ + else \ + output="mta-ops_${os}_${arch}"; \ + fi && \ + echo "Building standalone binary $output (version=${MTA_OPS_VERSION})..." && \ + CGO_ENABLED=0 GOOS="$os" GOARCH="$arch" go build -trimpath -mod=readonly \ + -ldflags="-X github.com/konveyor/crane/internal/buildinfo.Version=${CRANE_VERSION}" \ + -o "/tmp/archives/$output" ./main.go && \ + (cd /tmp/archives && sha256sum "$output" > "$output.sha256"); \ + done && \ + cp LICENSE /tmp/archives/LICENSE && \ + go clean -cache -modcache -testcache && \ + rm -rf /opt/app-root/src/.cache /opt/app-root/src/go/pkg /tmp/go /tmp/.cache + +RUN CGO_ENABLED=0 GOOS=${TARGETOS} GOARCH=${TARGETARCH} go build -trimpath -mod=readonly \ + -ldflags="-X github.com/konveyor/crane/internal/buildinfo.Version=${BUILD_VERSION}" \ + -o /tmp/bin/mta-ops ./main.go + +FROM registry.access.redhat.com/ubi9:latest + +RUN dnf -y install openssl && dnf -y reinstall tzdata && dnf clean all + +COPY --from=builder /tmp/archives /archives +COPY --from=builder /tmp/bin/mta-ops /usr/local/bin/mta-ops +COPY LICENSE /licenses/ + +USER 1001 + +ENTRYPOINT ["/usr/local/bin/mta-ops"] + +LABEL \ + description="MTA-OPS CLI for Kubernetes migration workflows" \ + io.k8s.description="MTA-Ops CLI for Kubernetes migration workflows" \ + io.k8s.display-name="MTA-Ops CLI" \ + io.openshift.maintainer.project="MTA-Ops" \ + io.openshift.tags="migration,modernization,konveyor,mta-ops" \ + summary="MTA-Ops CLI" From 54e2e50e84ba8c0208be9c64fa56a64b55126095 Mon Sep 17 00:00:00 2001 From: M Sajid Mansoori Date: Thu, 14 May 2026 17:11:42 +0530 Subject: [PATCH 2/6] Update dockerfile Signed-off-by: M Sajid Mansoori --- konflux.Dockerfile | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/konflux.Dockerfile b/konflux.Dockerfile index bd48be51..8b1d23df 100644 --- a/konflux.Dockerfile +++ b/konflux.Dockerfile @@ -3,13 +3,13 @@ FROM registry.redhat.io/ubi9/go-toolset:1.25 AS builder COPY . /workspace WORKDIR /workspace -ARG BUILD_VERSION=v0.0.0 -ARG SOURCE_GIT_COMMIT=unknown ARG TARGETOS=linux ARG TARGETARCH=amd64 RUN set -e && \ + # Prefer ART/Konflux injected env vars; fall back for local builds. MTA_OPS_VERSION="${BUILD_VERSION:-dev}" && \ + MTA_OPS_GIT_COMMIT="${SOURCE_GIT_COMMIT:-unknown}" && \ mkdir -p /tmp/archives /tmp/bin && \ for platform in linux/amd64 linux/arm64 darwin/amd64 darwin/arm64 windows/amd64 windows/arm64; do \ os=$(echo "$platform" | cut -d'/' -f1) && \ @@ -19,9 +19,9 @@ RUN set -e && \ else \ output="mta-ops_${os}_${arch}"; \ fi && \ - echo "Building standalone binary $output (version=${MTA_OPS_VERSION})..." && \ + echo "Building standalone binary $output (version=${MTA_OPS_VERSION}, commit=${MTA_OPS_GIT_COMMIT})..." && \ CGO_ENABLED=0 GOOS="$os" GOARCH="$arch" go build -trimpath -mod=readonly \ - -ldflags="-X github.com/konveyor/crane/internal/buildinfo.Version=${CRANE_VERSION}" \ + -ldflags="-X github.com/konveyor/crane/internal/buildinfo.Version=${MTA_OPS_VERSION}" \ -o "/tmp/archives/$output" ./main.go && \ (cd /tmp/archives && sha256sum "$output" > "$output.sha256"); \ done && \ @@ -29,8 +29,9 @@ RUN set -e && \ go clean -cache -modcache -testcache && \ rm -rf /opt/app-root/src/.cache /opt/app-root/src/go/pkg /tmp/go /tmp/.cache -RUN CGO_ENABLED=0 GOOS=${TARGETOS} GOARCH=${TARGETARCH} go build -trimpath -mod=readonly \ - -ldflags="-X github.com/konveyor/crane/internal/buildinfo.Version=${BUILD_VERSION}" \ +RUN MTA_OPS_VERSION="${BUILD_VERSION:-dev}" && \ + CGO_ENABLED=0 GOOS=${TARGETOS} GOARCH=${TARGETARCH} go build -trimpath -mod=readonly \ + -ldflags="-X github.com/konveyor/crane/internal/buildinfo.Version=${MTA_OPS_VERSION}" \ -o /tmp/bin/mta-ops ./main.go FROM registry.access.redhat.com/ubi9:latest From 36c943e053d685867de23121050f6d7579153120 Mon Sep 17 00:00:00 2001 From: M Sajid Mansoori Date: Fri, 15 May 2026 10:43:43 +0530 Subject: [PATCH 3/6] Minor change Signed-off-by: M Sajid Mansoori --- konflux.Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/konflux.Dockerfile b/konflux.Dockerfile index 8b1d23df..a2e0f19b 100644 --- a/konflux.Dockerfile +++ b/konflux.Dockerfile @@ -47,7 +47,7 @@ USER 1001 ENTRYPOINT ["/usr/local/bin/mta-ops"] LABEL \ - description="MTA-OPS CLI for Kubernetes migration workflows" \ + description="MTA-Ops CLI for Kubernetes migration workflows" \ io.k8s.description="MTA-Ops CLI for Kubernetes migration workflows" \ io.k8s.display-name="MTA-Ops CLI" \ io.openshift.maintainer.project="MTA-Ops" \ From 1a93c30e7dead7faa28be5490b7bfe21f1240cdc Mon Sep 17 00:00:00 2001 From: M Sajid Mansoori Date: Mon, 18 May 2026 10:36:25 +0530 Subject: [PATCH 4/6] Update dockerfile Signed-off-by: M Sajid Mansoori --- konflux.Dockerfile | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/konflux.Dockerfile b/konflux.Dockerfile index a2e0f19b..0cee6d11 100644 --- a/konflux.Dockerfile +++ b/konflux.Dockerfile @@ -25,15 +25,16 @@ RUN set -e && \ -o "/tmp/archives/$output" ./main.go && \ (cd /tmp/archives && sha256sum "$output" > "$output.sha256"); \ done && \ + if [ "${TARGETOS}" = "windows" ]; then \ + runtime_output="mta-ops_${TARGETOS}_${TARGETARCH}.exe"; \ + else \ + runtime_output="mta-ops_${TARGETOS}_${TARGETARCH}"; \ + fi && \ + cp "/tmp/archives/${runtime_output}" /tmp/bin/mta-ops && \ cp LICENSE /tmp/archives/LICENSE && \ go clean -cache -modcache -testcache && \ rm -rf /opt/app-root/src/.cache /opt/app-root/src/go/pkg /tmp/go /tmp/.cache -RUN MTA_OPS_VERSION="${BUILD_VERSION:-dev}" && \ - CGO_ENABLED=0 GOOS=${TARGETOS} GOARCH=${TARGETARCH} go build -trimpath -mod=readonly \ - -ldflags="-X github.com/konveyor/crane/internal/buildinfo.Version=${MTA_OPS_VERSION}" \ - -o /tmp/bin/mta-ops ./main.go - FROM registry.access.redhat.com/ubi9:latest RUN dnf -y install openssl && dnf -y reinstall tzdata && dnf clean all From cf31c66ed2cd134a8b9bdc5f5a5838b1f732f874 Mon Sep 17 00:00:00 2001 From: M Sajid Mansoori Date: Mon, 18 May 2026 11:04:05 +0530 Subject: [PATCH 5/6] Add commit info as part of version command for better tracking Signed-off-by: M Sajid Mansoori --- cmd/version/version.go | 1 + internal/buildinfo/buildinfo.go | 1 + konflux.Dockerfile | 2 +- 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/cmd/version/version.go b/cmd/version/version.go index 72e83ee8..6eae9b75 100644 --- a/cmd/version/version.go +++ b/cmd/version/version.go @@ -60,6 +60,7 @@ func NewVersionCommand(f *flags.GlobalFlags) *cobra.Command { func (o *Options) run() error { fmt.Println("crane:") fmt.Printf("\tVersion: %s\n", buildinfo.Version) + fmt.Printf("\tSHA: %s\n", buildinfo.BuildCommit) fmt.Println("crane-lib:") fmt.Printf("\tVersion: %s\n", buildinfo.CranelibVersion) return nil diff --git a/internal/buildinfo/buildinfo.go b/internal/buildinfo/buildinfo.go index 17ed26e5..914e85ec 100644 --- a/internal/buildinfo/buildinfo.go +++ b/internal/buildinfo/buildinfo.go @@ -8,4 +8,5 @@ var ( Version string = "v0.0.6" CranelibVersion string = cranelibversion.Version + BuildCommit string = "" ) diff --git a/konflux.Dockerfile b/konflux.Dockerfile index 0cee6d11..0081ce31 100644 --- a/konflux.Dockerfile +++ b/konflux.Dockerfile @@ -21,7 +21,7 @@ RUN set -e && \ fi && \ echo "Building standalone binary $output (version=${MTA_OPS_VERSION}, commit=${MTA_OPS_GIT_COMMIT})..." && \ CGO_ENABLED=0 GOOS="$os" GOARCH="$arch" go build -trimpath -mod=readonly \ - -ldflags="-X github.com/konveyor/crane/internal/buildinfo.Version=${MTA_OPS_VERSION}" \ + -ldflags="-X github.com/konveyor/crane/internal/buildinfo.Version=${MTA_OPS_VERSION} -X github.com/konveyor/crane/internal/buildinfo.BuildCommit=${MTA_OPS_GIT_COMMIT}" \ -o "/tmp/archives/$output" ./main.go && \ (cd /tmp/archives && sha256sum "$output" > "$output.sha256"); \ done && \ From 72f67b2393a67d9694659c735e323a500c823345 Mon Sep 17 00:00:00 2001 From: M Sajid Mansoori Date: Mon, 18 May 2026 11:18:19 +0530 Subject: [PATCH 6/6] Add comments for overriding values for version and buildcommit Signed-off-by: M Sajid Mansoori --- internal/buildinfo/buildinfo.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/internal/buildinfo/buildinfo.go b/internal/buildinfo/buildinfo.go index 914e85ec..8bda3d17 100644 --- a/internal/buildinfo/buildinfo.go +++ b/internal/buildinfo/buildinfo.go @@ -5,6 +5,8 @@ import ( ) var ( + // Version and BuildCommit can be overridden at build time with: + // go build -ldflags="-X github.com/konveyor/crane/internal/buildinfo.Version= -X github.com/konveyor/crane/internal/buildinfo.BuildCommit=$(git rev-parse HEAD)" Version string = "v0.0.6" CranelibVersion string = cranelibversion.Version