Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 10 additions & 9 deletions components/tensorboard-controller/Dockerfile
Copy link
Contributor

Choose a reason for hiding this comment

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

So I appreciate you trying to restructure this Dockerfile a bit - as I realize and appreciate it was confusing - with its implementation not actually aligning to the inline comments 😢

However, I would suggest a slightly different approach to "fixing" this (in addition to the 1.24 upgrade). I think the pvcviewer-controller Dockerfile is a good implementation (in which various commands actually DO clearly align with the comments in the file). Using that as inspiration - I would suggest the following as the entirety of this file's contents:

# Build the manager binary
ARG GOLANG_VERSION=1.24
FROM golang:${GOLANG_VERSION} as builder

WORKDIR /workspace
# Copy the Go Modules manifests
COPY tensorboard-controller/go.mod go.mod
COPY tensorboard-controller/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 tensorboard-controller/main.go main.go
COPY tensorboard-controller/api/ api/
COPY tensorboard-controller/controllers/ controllers/
COPY tensorboard-controller/reconcilehelper/ reconcilehelper/

# Build
RUN CGO_ENABLED=0 GOOS=linux go build -a -o manager main.go

# Use distroless as minimal base image to package the manager binary
# Refer to https://github.com/GoogleContainerTools/distroless for more details
FROM gcr.io/distroless/static:nonroot
WORKDIR /
COPY --from=builder /workspace/manager .
USER 65532:65532

ENTRYPOINT ["/manager"]

Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,26 @@
#
# ${PATH_TO_KUBEFLOW/KUBEFLOW repo}/components
#
FROM golang:1.17 as builder
FROM golang:1.24 as builder

WORKDIR /workspace
# Copy the Go Modules manifests
COPY tensorboard-controller /workspace/tensorboard-controller
WORKDIR /workspace/tensorboard-controller
# 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 cd /workspace/tensorboard-controller && go mod download

WORKDIR /workspace/tensorboard-controller
# Copy only Go module files first for better layer caching
COPY tensorboard-controller/go.mod tensorboard-controller/go.sum ./
# Download dependencies based on mod files
RUN go mod download
# Now copy the full source
COPY tensorboard-controller/ ./

# Build
RUN CGO_ENABLED=0 GOOS=linux GO111MODULE=on go build -a -o manager main.go
RUN CGO_ENABLED=0 GOOS=linux go build -a -o /manager main.go

# Use distroless as minimal base image to package the manager binary
# Refer to https://github.com/GoogleContainerTools/distroless for more details
FROM gcr.io/distroless/static:nonroot
WORKDIR /
COPY --from=builder /workspace/tensorboard-controller/manager .
COPY --from=builder /manager /manager
USER 65532:65532

ENTRYPOINT ["/manager"]
2 changes: 1 addition & 1 deletion components/tensorboard-controller/go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/kubeflow/notebooks/components/tensorboard-controller

go 1.17
go 1.24

require (
github.com/go-logr/logr v1.2.0
Expand Down