-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild_image.sh
More file actions
executable file
·62 lines (52 loc) · 1.5 KB
/
build_image.sh
File metadata and controls
executable file
·62 lines (52 loc) · 1.5 KB
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
echo "Buiding solver docker image..."
# Choose the environment
PS3="Please choose the environment: "
options=("dev" "prod" "quit")
select OPT in "${options[@]}"
do
case ${OPT} in
"dev")
echo "Using dev environment"
break
;;
"prod")
echo "Using prod environment"
break
;;
"quit")
exit
;;
*) echo "invalid option $REPLY";;
esac
done
test -d target && rm -rf target
. .version
# Increment version build number
if [ "${OPT}" == "dev" ]; then
BUILD=$(echo ${BUILD_VERSION} | cut -f 3 -d ".")
VER=$(echo ${BUILD_VERSION} | cut -f 1,2 -d ".")
BUILD=$((${BUILD} + 1))
BUILD_VERSION="${VER}.${BUILD}"
echo "BUILD_VERSION=${BUILD_VERSION}" > .version
cargo set-version ${BUILD_VERSION}
fi
echo "Running docker build for version ${BUILD_VERSION}"
set -e
CLOUD_REGION="us-central1"
PROJECT_NAME="solver-438012"
DOCKER_IMAGE="solver-docker-repo/blockclock-solver-image"
DOCKER_TAG="${CLOUD_REGION}-docker.pkg.dev/${PROJECT_NAME}/${DOCKER_IMAGE}"
CURRENT_PROJECT=$(gcloud config get project)
echo ${CURRENT_PROJECT}
if [ "${PROJECT_NAME}" != "${CURRENT_PROJECT}" ]; then
gcloud auth login
gcloud config set project ${PROJECT_NAME}
fi
if [ "${OPT}" == "dev" ]; then
echo "Building and pushing docker image..."
gcloud builds submit \
--region=${CLOUD_REGION} \
--tag ${DOCKER_TAG}:${BUILD_VERSION}
fi
echo "Tagging Docker image as current ${OPT}..."
gcloud artifacts docker tags add ${DOCKER_TAG}:${BUILD_VERSION} ${DOCKER_TAG}:${OPT}