From 9a6ae63bce1b8e48ec245829e1e663b8526b1784 Mon Sep 17 00:00:00 2001 From: huimin Date: Fri, 9 Aug 2019 00:27:18 +0800 Subject: [PATCH] Use multi-build to build pytorch-operator image (#198) * Use multi-build to build pytorch-operator image Use multi-build to build pytorch-operator image. * Update Dockerfile * Update Dockerfile --- .gcloudignore | 2 +- Dockerfile | 15 +++++++++++++-- scripts/build.sh | 6 ------ 3 files changed, 14 insertions(+), 9 deletions(-) diff --git a/.gcloudignore b/.gcloudignore index 7aada99c8..bee692559 100644 --- a/.gcloudignore +++ b/.gcloudignore @@ -4,4 +4,4 @@ .git .gitignore #!include:.gitignore -vendor +#vendor diff --git a/Dockerfile b/Dockerfile index 6458174d4..b6f701235 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,17 @@ +FROM golang:1.12 AS build-image + +ADD . /go/src/github.com/kubeflow/pytorch-operator + +WORKDIR /go/src/github.com/kubeflow/pytorch-operator + +# Build pytorch operator v1beta2 binary +RUN go build ./cmd/pytorch-operator.v1beta2 +# Build pytorch operator v1 binary +RUN go build ./cmd/pytorch-operator.v1 + FROM registry.access.redhat.com/ubi8/ubi:latest -COPY pytorch-operator.v1beta2 /pytorch-operator.v1beta2 -COPY pytorch-operator.v1 /pytorch-operator.v1 +COPY --from=build-image /go/src/github.com/kubeflow/pytorch-operator/pytorch-operator.v1beta2 /pytorch-operator.v1beta2 +COPY --from=build-image /go/src/github.com/kubeflow/pytorch-operator/pytorch-operator.v1 /pytorch-operator.v1 ENTRYPOINT ["/pytorch-operator", "-alsologtostderr"] diff --git a/scripts/build.sh b/scripts/build.sh index 43fd71289..cdb0e22f3 100755 --- a/scripts/build.sh +++ b/scripts/build.sh @@ -33,12 +33,6 @@ mkdir -p ${GOPATH}/src/github.com/${REPO_OWNER} ln -s ${PWD} ${GO_DIR} cd ${GO_DIR} -echo "Build pytorch operator v1beta2 binary" -go build github.com/kubeflow/pytorch-operator/cmd/pytorch-operator.v1beta2 - -echo "Build pytorch operator v1 binary" -go build github.com/kubeflow/pytorch-operator/cmd/pytorch-operator.v1 - echo "Building PyTorch operator in gcloud" gcloud version gcloud builds submit . --tag=${REGISTRY}/${REPO_NAME}:${VERSION} --project=${PROJECT}