Skip to content

Commit eae9e23

Browse files
liavweissLiav Weiss (EXT-Nokia)thesuperzapper
authored andcommitted
fix(ws): backend dockerfile (kubeflow#386)
* feat(ws): Properly containerize backend component kubeflow#323 Signed-off-by: Liav Weiss (EXT-Nokia) <[email protected]> * feat(ws): Properly containerize backend component kubeflow#323 Signed-off-by: Liav Weiss (EXT-Nokia) <[email protected]> * feat(ws): Properly containerize backend component kubeflow#323 Signed-off-by: Liav Weiss (EXT-Nokia) <[email protected]> * mathew: revert typo Signed-off-by: Mathew Wicks <[email protected]> --------- Signed-off-by: Liav Weiss (EXT-Nokia) <[email protected]> Signed-off-by: Mathew Wicks <[email protected]> Co-authored-by: Liav Weiss (EXT-Nokia) <[email protected]> Co-authored-by: Mathew Wicks <[email protected]>
1 parent b6e664c commit eae9e23

File tree

3 files changed

+24
-13
lines changed

3 files changed

+24
-13
lines changed

workspaces/.dockerignore

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# NOTE: This file is used when building Docker images with context `..`
2+
# Primarily intended for backend/Dockerfile builds
3+
4+
# Exclude frontend code, node_modules, and unnecessary binaries
5+
frontend/
6+
controller/bin/
7+
backend/bin/

workspaces/backend/Dockerfile

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,20 @@ ARG TARGETARCH
66
WORKDIR /workspace
77

88
# Copy the Go Modules manifests
9-
COPY go.mod go.sum ./
9+
COPY backend/go.mod backend/go.sum ./
1010

11-
# Download dependencies
12-
RUN go mod download
11+
# Copy controller directory
12+
COPY controller /workspace/controller
13+
14+
# Rewrite the go.mod to update the replace directive and download dependencies
15+
RUN go mod edit -replace=github.com/kubeflow/notebooks/workspaces/controller=./controller && \
16+
go mod download
1317

1418
# Copy the go source files
15-
COPY cmd/ cmd/
16-
COPY api/ api/
17-
COPY config/ config/
18-
COPY data/ data/
19-
COPY integrations/ integrations/
19+
COPY backend/cmd/ cmd/
20+
COPY backend/api/ api/
21+
COPY backend/internal/ internal/
22+
COPY backend/openapi/ openapi/
2023

2124
# Build the Go application
2225
RUN CGO_ENABLED=0 GOOS=${TARGETOS:-linux} GOARCH=${TARGETARCH} go build -a -o backend ./cmd/main.go
@@ -31,7 +34,7 @@ USER 65532:65532
3134
EXPOSE 4000
3235

3336
# Define environment variables
34-
ENV PORT 4000
35-
ENV ENV development
37+
ENV PORT=4000
38+
ENV ENV=development
3639

3740
ENTRYPOINT ["/backend"]

workspaces/backend/Makefile

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,8 @@ run: fmt vet swag ## Run a backend from your host.
9191
# More info: https://docs.docker.com/develop/develop-images/build_enhancements/
9292
.PHONY: docker-build
9393
docker-build: ## Build docker image with the backend.
94-
$(CONTAINER_TOOL) build -t ${IMG} .
94+
$(CONTAINER_TOOL) build -f Dockerfile -t $(IMG) ..
95+
9596

9697
.PHONY: docker-push
9798
docker-push: ## Push docker image with the backend.
@@ -107,10 +108,10 @@ PLATFORMS ?= linux/arm64,linux/amd64,linux/s390x,linux/ppc64le
107108
.PHONY: docker-buildx
108109
docker-buildx: ## Build and push docker image for the manager for cross-platform support
109110
# copy existing Dockerfile and insert --platform=${BUILDPLATFORM} into Dockerfile.cross, and preserve the original Dockerfile
110-
sed -e '1 s/\(^FROM\)/FROM --platform=\$$\{BUILDPLATFORM\}/; t' -e ' 1,// s//FROM --platform=\$$\{BUILDPLATFORM\}/' Dockerfile > Dockerfile.cross
111+
sed '1,// s/^FROM/FROM --platform=$${BUILDPLATFORM}/' Dockerfile > Dockerfile.cross
111112
- $(CONTAINER_TOOL) buildx create --name project-v3-builder
112113
$(CONTAINER_TOOL) buildx use project-v3-builder
113-
- $(CONTAINER_TOOL) buildx build --push --platform=$(PLATFORMS) --tag ${IMG} -f Dockerfile.cross .
114+
- $(CONTAINER_TOOL) buildx build --push --platform=$(PLATFORMS) --tag ${IMG} -f Dockerfile.cross ..
114115
- $(CONTAINER_TOOL) buildx rm project-v3-builder
115116
rm Dockerfile.cross
116117

0 commit comments

Comments
 (0)