forked from kubeflow/pytorch-operator
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild_image.sh
executable file
·30 lines (27 loc) · 977 Bytes
/
build_image.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#!/bin/bash
#
# A simple script to build the Docker images.
# This is intended to be invoked as a step in Argo to build the docker image.
#
# build_image.sh ${DOCKERFILE} ${IMAGE} ${TAG} {ROOT_DIR}
set -ex
DOCKERFILE=$1
CONTEXT_DIR=$(dirname "$DOCKERFILE")
IMAGE=$2
TAG=$3
ROOT_DIR=$4
export GOPATH=${ROOT_DIR}
GO_DIR=${GOPATH}/src/github.com/kubeflow/pytorch-operator
gcloud auth activate-service-account --key-file=${GOOGLE_APPLICATION_CREDENTIALS}
export PATH=${GOPATH}/bin:/usr/local/go/bin:${PATH}
echo "Create symlink to GOPATH"
mkdir -p ${GOPATH}/src/github.com/kubeflow
ln -s ${CONTEXT_DIR} ${GO_DIR}
cd ${GO_DIR}
echo "Build pytorch operator v1alpha1 binary"
go build github.com/kubeflow/pytorch-operator/cmd/pytorch-operator
echo "Build pytorch operator v1alpha2 binary"
go build github.com/kubeflow/pytorch-operator/cmd/pytorch-operator.v2
echo "Building container in gcloud"
gcloud container builds submit . --tag=${IMAGE}:${TAG}
echo "Image built successfully"