diff --git a/backend/Dockerfile b/backend/Dockerfile index fc8d1ca8467..fa00a150a1e 100644 --- a/backend/Dockerfile +++ b/backend/Dockerfile @@ -1,3 +1,4 @@ + # Copyright 2021-2022 The Kubeflow Authors # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -35,10 +36,15 @@ RUN python3 -m pip install -r requirements.txt --no-cache-dir # Downloading Argo CLI so that the samples are validated ENV ARGO_VERSION v3.4.17 -RUN curl -sLO https://github.com/argoproj/argo-workflows/releases/download/${ARGO_VERSION}/argo-linux-amd64.gz && \ - gunzip argo-linux-amd64.gz && \ - chmod +x argo-linux-amd64 && \ - mv ./argo-linux-amd64 /usr/local/bin/argo +#Support s390x and ppc64le +RUN ARCH=$(uname -m); \ + if [ "$ARCH" = "x86_64" ]; then \ + ARCH="amd64"; \ + fi \ + && curl -sLO https://github.com/argoproj/argo-workflows/releases/download/${ARGO_VERSION}/argo-linux-${ARCH}.gz && \ + gunzip argo-linux-${ARCH}.gz && \ + chmod +x argo-linux-${ARCH} && \ + mv ./argo-linux-${ARCH} /usr/local/bin/argo WORKDIR / COPY ./samples /samples diff --git a/backend/Dockerfile.driver b/backend/Dockerfile.driver index 4f34cb42851..030dac69aad 100644 --- a/backend/Dockerfile.driver +++ b/backend/Dockerfile.driver @@ -1,3 +1,4 @@ + # Copyright 2023 The Kubeflow Authors # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -17,7 +18,12 @@ FROM golang:1.21.7-alpine3.19 as builder WORKDIR /go/src/github.com/kubeflow/pipelines COPY . . -RUN GO111MODULE=on CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -tags netgo -ldflags '-extldflags "-static"' -o /bin/driver ./backend/src/v2/cmd/driver/*.go +RUN ARCH=$(uname -m) && \ + if [ "$ARCH" = "x86_64" ]; then \ + ARCH="amd64"; \ + fi && \ + GO111MODULE=on CGO_ENABLED=0 GOOS=linux GOARCH=$ARCH go build -tags netgo -ldflags '-extldflags "-static"' -o /bin/driver ./backend/src/v2/cmd/driver/*.go + # Check licenses and comply with license terms. RUN ./hack/install-go-licenses.sh diff --git a/backend/Dockerfile.launcher b/backend/Dockerfile.launcher index 30fc8b05789..171c3495450 100644 --- a/backend/Dockerfile.launcher +++ b/backend/Dockerfile.launcher @@ -17,7 +17,11 @@ FROM golang:1.21.7-alpine3.19 as builder WORKDIR /go/src/github.com/kubeflow/pipelines COPY . . -RUN GO111MODULE=on CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -tags netgo -ldflags '-extldflags "-static"' -o /bin/launcher-v2 ./backend/src/v2/cmd/launcher-v2/*.go +RUN ARCH=$(uname -m) && \ + if [ "$ARCH" = "x86_64" ]; then \ + ARCH="amd64"; \ + fi && \ + GO111MODULE=on CGO_ENABLED=0 GOOS=linux GOARCH=$ARCH go build -tags netgo -ldflags '-extldflags "-static"' -o /bin/launcher-v2 ./backend/src/v2/cmd/launcher-v2/*.go # Check licenses and comply with license terms. RUN ./hack/install-go-licenses.sh diff --git a/backend/Makefile b/backend/Makefile index 583a0d6674e..39ad20e7615 100644 --- a/backend/Makefile +++ b/backend/Makefile @@ -4,6 +4,7 @@ CSV_PATH=backend/third_party_licenses # Container Build Params CONTAINER_ENGINE ?= docker +PLATFORMS ?= linux/amd64,linux/s390x,linux/ppc64le IMG_TAG_APISERVER ?= apiserver IMG_TAG_PERSISTENCEAGENT ?= persistence-agent IMG_TAG_CACHESERVER ?= cache-server @@ -66,25 +67,25 @@ image_all: image_apiserver image_persistence_agent image_cache image_swf image_v .PHONY: image_apiserver image_apiserver: - cd $(MOD_ROOT) && ${CONTAINER_ENGINE} build -t ${IMG_TAG_APISERVER} -f backend/Dockerfile . + cd $(MOD_ROOT) && ${CONTAINER_ENGINE} buildx build --platform $(PLATFORMS) -t ${IMG_TAG_APISERVER} -f backend/Dockerfile . .PHONY: image_persistence_agent image_persistence_agent: - cd $(MOD_ROOT) && ${CONTAINER_ENGINE} build -t ${IMG_TAG_PERSISTENCEAGENT} -f backend/Dockerfile.persistenceagent . + cd $(MOD_ROOT) && ${CONTAINER_ENGINE} buildx build --platform $(PLATFORMS) -t ${IMG_TAG_PERSISTENCEAGENT} -f backend/Dockerfile.persistenceagent . .PHONY: image_cache image_cache: - cd $(MOD_ROOT) && ${CONTAINER_ENGINE} build -t ${IMG_TAG_CACHESERVER} -f backend/Dockerfile.cacheserver . -.PHONY: image_swf + cd $(MOD_ROOT) && ${CONTAINER_ENGINE} buildx build --platform $(PLATFORMS) -t ${IMG_TAG_CACHESERVER} -f backend/Dockerfile.cacheserver . +.PHONY: image_swf image_swf: - cd $(MOD_ROOT) && ${CONTAINER_ENGINE} build -t ${IMG_TAG_SCHEDULEDWORKFLOW} -f backend/Dockerfile.scheduledworkflow . + cd $(MOD_ROOT) && ${CONTAINER_ENGINE} buildx build --platform $(PLATFORMS) -t ${IMG_TAG_SCHEDULEDWORKFLOW} -f backend/Dockerfile.scheduledworkflow . .PHONY: image_viewer image_viewer: - cd $(MOD_ROOT) && ${CONTAINER_ENGINE} build -t ${IMG_TAG_VIEWERCONTROLLER} -f backend/Dockerfile.viewercontroller . + cd $(MOD_ROOT) && ${CONTAINER_ENGINE} buildx build --platform $(PLATFORMS) -t ${IMG_TAG_VIEWERCONTROLLER} -f backend/Dockerfile.viewercontroller . .PHONY: image_visualization image_visualization: cd $(MOD_ROOT) && ${CONTAINER_ENGINE} build -t ${IMG_TAG_VISUALIZATION} -f backend/Dockerfile.visualization . .PHONY: image_driver image_driver: - cd $(MOD_ROOT) && ${CONTAINER_ENGINE} build -t ${IMG_TAG_DRIVER} -f backend/Dockerfile.driver . + cd $(MOD_ROOT) && ${CONTAINER_ENGINE} buildx build --platform $(PLATFORMS) -t ${IMG_TAG_DRIVER} -f backend/Dockerfile.driver . .PHONY: image_launcher image_launcher: - cd $(MOD_ROOT) && ${CONTAINER_ENGINE} build -t ${IMG_TAG_LAUNCHER} -f backend/Dockerfile.launcher . + cd $(MOD_ROOT) && ${CONTAINER_ENGINE} buildx build --platform $(PLATFORMS)-t ${IMG_TAG_LAUNCHER} -f backend/Dockerfile.launcher . diff --git a/backend/api/Dockerfile b/backend/api/Dockerfile index 786ad2c0d3b..a9897eba1a3 100644 --- a/backend/api/Dockerfile +++ b/backend/api/Dockerfile @@ -23,7 +23,8 @@ ENV GOBIN=/go/bin # Install protoc. RUN apt-get update -y && apt-get install -y jq sed unzip -RUN curl -L -o protoc.zip https://github.com/protocolbuffers/protobuf/releases/download/v${PROTOC_VERSION}/protoc-${PROTOC_VERSION}-linux-x86_64.zip +RUN ARCH=$(uname -m); \ + && curl -L -o protoc.zip https://github.com/protocolbuffers/protobuf/releases/download/v${PROTOC_VERSION}/protoc-${PROTOC_VERSION}-linux-${ARCH}.zip RUN unzip -o protoc.zip -d /usr/ bin/protoc RUN unzip -o protoc.zip -d /usr/ 'include/*' RUN rm -f protoc.zip @@ -41,8 +42,26 @@ RUN go install github.com/grpc-ecosystem/grpc-gateway/protoc-gen-grpc-gateway@la RUN go install github.com/grpc-ecosystem/grpc-gateway/protoc-gen-swagger@latest # Download go-swagger binary. -RUN curl -LO "https://github.com/go-swagger/go-swagger/releases/download/${GO_SWAGGER_VERSION}/swagger_linux_amd64" -RUN chmod +x swagger_linux_amd64 && mv swagger_linux_amd64 /usr/bin/swagger +#building go-swagger binary for s390x and ppc64le since pre built binaries are not available for these platforms +RUN /bin/sh -c ARCH=$(uname -m) && \ + if [ "$ARCH" = "x86_64" ]; then \ + ARCH="amd64" && \ + curl -LO "https://github.com/go-swagger/go-swagger/releases/download/${GO_SWAGGER_VERSION}/swagger_linux_${ARCH}" && \ + chmod +x swagger_linux_${ARCH} && \ + mv swagger_linux_${ARCH} /usr/bin/swagger; \ + else \ + dir=$(mktemp -d) && \ + git clone https://github.com/go-swagger/go-swagger "$dir" && \ + cd "$dir" && \ + git checkout v${GO_SWAGGER_VERSION} && \ + LDFLAGS="-s -w -X github.com/$GITHUB_REPOSITORY/cmd/swagger/commands.Commit=${GITHUB_SHA}"; \ + LDFLAGS="$LDFLAGS -X github.com/$GITHUB_REPOSITORY/cmd/swagger/commands.Version=${GITHUB_REF_NAME-dev}"; \ + out="swagger_linux_$ARCH"; \ + GOOS=linux GOARCH=$ARCH CGO_ENABLED=0 go build -ldflags "$LDFLAGS" -o "./dist/bin/$out" ./cmd/swagger; \ + mv "./dist/bin/$out" /usr/bin/swagger && \ + cd / && \ + rm -rf "$dir"; \ + fi # Need protobuf source code for -I in protoc command. RUN mkdir golang && cd golang && git clone --depth 1 --branch $GOLANG_PROTOBUF_VERSION https://github.com/golang/protobuf.git diff --git a/backend/src/cache/deployer/Dockerfile b/backend/src/cache/deployer/Dockerfile index abae217a73f..6e6103f41c4 100644 --- a/backend/src/cache/deployer/Dockerfile +++ b/backend/src/cache/deployer/Dockerfile @@ -1,11 +1,17 @@ -FROM gcr.io/google.com/cloudsdktool/google-cloud-cli:alpine +FROM alpine RUN apk add --update \ curl \ jq \ openssl -RUN gcloud components install kubectl + RUN ARCH=$(uname -m); \ + if [ "$ARCH" = "x86_64" ]; then \ + ARCH="amd64"; \ + fi \ + && curl -LO https://storage.googleapis.com/kubernetes-release/release/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/linux/${ARCH}/kubectl \ + && chmod +x ./kubectl \ + && mv ./kubectl /usr/local/bin/kubectl ADD backend/src/cache/deployer/* /kfp/cache/deployer/ RUN chmod -R 777 /kfp/cache/deployer diff --git a/backend/src/cache/deployer/deploy-cache-service.sh b/backend/src/cache/deployer/deploy-cache-service.sh index 9d8ac9b6b01..f027ea69b86 100755 --- a/backend/src/cache/deployer/deploy-cache-service.sh +++ b/backend/src/cache/deployer/deploy-cache-service.sh @@ -35,7 +35,16 @@ export PATH="$HOME/bin:$PATH" { server_version_major_minor=$(kubectl version --output json | jq --raw-output '(.serverVersion.major + "." + .serverVersion.minor)' | tr -d '"+') stable_build_version=$(curl -s "https://storage.googleapis.com/kubernetes-release/release/stable-${server_version_major_minor}.txt") - kubectl_url="https://storage.googleapis.com/kubernetes-release/release/${stable_build_version}/bin/linux/amd64/kubectl" + if [ "$ARCH" = "amd64" ]; then + kubectl_url="https://storage.googleapis.com/kubernetes-release/release/${stable_build_version}/bin/linux/amd64/kubectl" + elif [ "$ARCH" = "s390x" ]; then #support for s390x + kubectl_url="https://storage.googleapis.com/kubernetes-release/release/${stable_build_version}/bin/linux/s390x/kubectl" + elif [ "$ARCH" = "ppc64le" ]; then # support for ppc64le + kubectl_url="https://storage.googleapis.com/kubernetes-release/release/${stable_build_version}/bin/linux/ppc64le/kubectl" + else + echo "Unsupported architecture: $ARCH" + exit 1 + fi curl -L -o "$HOME/bin/kubectl" "$kubectl_url" chmod +x "$HOME/bin/kubectl" } || true diff --git a/third_party/minio/Dockerfile b/third_party/minio/Dockerfile index 0c5cffcc7f8..be8f9d4dc47 100644 --- a/third_party/minio/Dockerfile +++ b/third_party/minio/Dockerfile @@ -23,7 +23,7 @@ RUN sh /third_party/download_source.sh