fix(ws): backend dockerfile (#386)
* feat(ws): Properly containerize backend component #323 Signed-off-by: Liav Weiss (EXT-Nokia) <liav.weiss.ext@nokia.com> * feat(ws): Properly containerize backend component #323 Signed-off-by: Liav Weiss (EXT-Nokia) <liav.weiss.ext@nokia.com> * feat(ws): Properly containerize backend component #323 Signed-off-by: Liav Weiss (EXT-Nokia) <liav.weiss.ext@nokia.com> * mathew: revert typo Signed-off-by: Mathew Wicks <5735406+thesuperzapper@users.noreply.github.com> --------- Signed-off-by: Liav Weiss (EXT-Nokia) <liav.weiss.ext@nokia.com> Signed-off-by: Mathew Wicks <5735406+thesuperzapper@users.noreply.github.com> Co-authored-by: Liav Weiss (EXT-Nokia) <liav.weiss.ext@nokia.com> Co-authored-by: Mathew Wicks <5735406+thesuperzapper@users.noreply.github.com>
This commit is contained in:
parent
ca3289c8d1
commit
42dfd30d94
|
@ -0,0 +1,7 @@
|
||||||
|
# NOTE: This file is used when building Docker images with context `..`
|
||||||
|
# Primarily intended for backend/Dockerfile builds
|
||||||
|
|
||||||
|
# Exclude frontend code, node_modules, and unnecessary binaries
|
||||||
|
frontend/
|
||||||
|
controller/bin/
|
||||||
|
backend/bin/
|
|
@ -6,17 +6,20 @@ ARG TARGETARCH
|
||||||
WORKDIR /workspace
|
WORKDIR /workspace
|
||||||
|
|
||||||
# Copy the Go Modules manifests
|
# Copy the Go Modules manifests
|
||||||
COPY go.mod go.sum ./
|
COPY backend/go.mod backend/go.sum ./
|
||||||
|
|
||||||
# Download dependencies
|
# Copy controller directory
|
||||||
RUN go mod download
|
COPY controller /workspace/controller
|
||||||
|
|
||||||
|
# Rewrite the go.mod to update the replace directive and download dependencies
|
||||||
|
RUN go mod edit -replace=github.com/kubeflow/notebooks/workspaces/controller=./controller && \
|
||||||
|
go mod download
|
||||||
|
|
||||||
# Copy the go source files
|
# Copy the go source files
|
||||||
COPY cmd/ cmd/
|
COPY backend/cmd/ cmd/
|
||||||
COPY api/ api/
|
COPY backend/api/ api/
|
||||||
COPY config/ config/
|
COPY backend/internal/ internal/
|
||||||
COPY data/ data/
|
COPY backend/openapi/ openapi/
|
||||||
COPY integrations/ integrations/
|
|
||||||
|
|
||||||
# Build the Go application
|
# Build the Go application
|
||||||
RUN CGO_ENABLED=0 GOOS=${TARGETOS:-linux} GOARCH=${TARGETARCH} go build -a -o backend ./cmd/main.go
|
RUN CGO_ENABLED=0 GOOS=${TARGETOS:-linux} GOARCH=${TARGETARCH} go build -a -o backend ./cmd/main.go
|
||||||
|
@ -31,7 +34,7 @@ USER 65532:65532
|
||||||
EXPOSE 4000
|
EXPOSE 4000
|
||||||
|
|
||||||
# Define environment variables
|
# Define environment variables
|
||||||
ENV PORT 4000
|
ENV PORT=4000
|
||||||
ENV ENV development
|
ENV ENV=development
|
||||||
|
|
||||||
ENTRYPOINT ["/backend"]
|
ENTRYPOINT ["/backend"]
|
||||||
|
|
|
@ -91,7 +91,8 @@ run: fmt vet swag ## Run a backend from your host.
|
||||||
# More info: https://docs.docker.com/develop/develop-images/build_enhancements/
|
# More info: https://docs.docker.com/develop/develop-images/build_enhancements/
|
||||||
.PHONY: docker-build
|
.PHONY: docker-build
|
||||||
docker-build: ## Build docker image with the backend.
|
docker-build: ## Build docker image with the backend.
|
||||||
$(CONTAINER_TOOL) build -t ${IMG} .
|
$(CONTAINER_TOOL) build -f Dockerfile -t $(IMG) ..
|
||||||
|
|
||||||
|
|
||||||
.PHONY: docker-push
|
.PHONY: docker-push
|
||||||
docker-push: ## Push docker image with the backend.
|
docker-push: ## Push docker image with the backend.
|
||||||
|
@ -107,10 +108,10 @@ PLATFORMS ?= linux/arm64,linux/amd64,linux/s390x,linux/ppc64le
|
||||||
.PHONY: docker-buildx
|
.PHONY: docker-buildx
|
||||||
docker-buildx: ## Build and push docker image for the manager for cross-platform support
|
docker-buildx: ## Build and push docker image for the manager for cross-platform support
|
||||||
# copy existing Dockerfile and insert --platform=${BUILDPLATFORM} into Dockerfile.cross, and preserve the original Dockerfile
|
# copy existing Dockerfile and insert --platform=${BUILDPLATFORM} into Dockerfile.cross, and preserve the original Dockerfile
|
||||||
sed -e '1 s/\(^FROM\)/FROM --platform=\$$\{BUILDPLATFORM\}/; t' -e ' 1,// s//FROM --platform=\$$\{BUILDPLATFORM\}/' Dockerfile > Dockerfile.cross
|
sed '1,// s/^FROM/FROM --platform=$${BUILDPLATFORM}/' Dockerfile > Dockerfile.cross
|
||||||
- $(CONTAINER_TOOL) buildx create --name project-v3-builder
|
- $(CONTAINER_TOOL) buildx create --name project-v3-builder
|
||||||
$(CONTAINER_TOOL) buildx use project-v3-builder
|
$(CONTAINER_TOOL) buildx use project-v3-builder
|
||||||
- $(CONTAINER_TOOL) buildx build --push --platform=$(PLATFORMS) --tag ${IMG} -f Dockerfile.cross .
|
- $(CONTAINER_TOOL) buildx build --push --platform=$(PLATFORMS) --tag ${IMG} -f Dockerfile.cross ..
|
||||||
- $(CONTAINER_TOOL) buildx rm project-v3-builder
|
- $(CONTAINER_TOOL) buildx rm project-v3-builder
|
||||||
rm Dockerfile.cross
|
rm Dockerfile.cross
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue