From 33ad099a82ed4c07a7c3852649a68e5bcf9e01c9 Mon Sep 17 00:00:00 2001 From: MohammadiIram Date: Wed, 9 Oct 2024 10:24:07 +0530 Subject: [PATCH] Review Dockerfile file for building odh-training-operator in konflux --- .../training-operator/Dockerfile.konflux | 43 +++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 build/images/training-operator/Dockerfile.konflux diff --git a/build/images/training-operator/Dockerfile.konflux b/build/images/training-operator/Dockerfile.konflux new file mode 100644 index 0000000000..75151566ab --- /dev/null +++ b/build/images/training-operator/Dockerfile.konflux @@ -0,0 +1,43 @@ +ARG SOURCE_CODE=. +ARG CI_CONTAINER_VERSION="unknown" +FROM registry.access.redhat.com/ubi8/go-toolset@sha256:4ec05fd5b355106cc0d990021a05b71bbfb9231e4f5bdc0c5316515edf6a1c96 as builder + + +WORKDIR /workspace +# Copy the Go Modules manifests +COPY go.mod go.mod +COPY go.sum go.sum +# cache deps before building and copying source so that we don't need to re-download as much +# and so that source changes don't invalidate our downloaded layer +RUN go mod download + +# Copy the go source +COPY . . + +# Build +USER root +RUN CGO_ENABLED=1 GOOS=linux GO111MODULE=on go build -tags strictfipsruntime -a -o manager cmd/training-operator.v1/main.go + +# Use distroless as minimal base image to package the manager binary +# Refer to https://github.com/GoogleContainerTools/distroless for more details +FROM registry.redhat.io/ubi8/ubi-minimal:latest AS runtime + +ARG CI_CONTAINER_VERSION +ARG USER=65532 + +LABEL com.redhat.component="odh-training-operator-container" \ + name="managed-open-data-hub/odh-training-operator-rhel8" \ + version="${CI_CONTAINER_VERSION}" \ + git.url="${CI_TRAINING_OPERATOR_UPSTREAM_URL}" \ + git.commit="${CI_TRAINING_OPERATOR_UPSTREAM_COMMIT}" \ + summary="odh-training-operator" \ + io.openshift.expose-services="" \ + io.k8s.display-name="odh-training-operator" \ + maintainer="['managed-open-data-hub@redhat.com']" \ + description="Training Operator is a Kubernetes-native project for fine-tuning and scalable distributed training of AI/ML models created with various frameworks such as PyTorch." \ + com.redhat.license_terms="https://www.redhat.com/licenses/Red_Hat_Standard_EULA_20191108.pdf" +WORKDIR / +COPY --from=builder /workspace/manager . +## Create a non-root user with UID 65532 and switch to it +USER ${USER}:${USER} +ENTRYPOINT ["/manager"]