forked from apache/datafusion-ballista
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild_and_push.sh
executable file
·42 lines (35 loc) · 1.2 KB
/
build_and_push.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
31
32
33
34
35
36
37
38
39
40
41
#!/usr/bin/env bash
set -x
set -e
VERSION=${VERSION:-latest} #"MR202008"
IMAGE_REPO_ADDRESS=${IMAGE_REPO_ADDRESS:-docker-cja-arrow-dev.dr-uw2.adobeitc.com}
DOCKER_BUILD_OPTIONS=${DOCKER_BUILD_OPTIONS:-""}
export DOCKER_BUILDKIT=1
export ARTIFACTORY_USER=${ARTIFACTORY_USER:-arrowops}
echo ${ARTIFACTORY_USER} > artifactory_user
export ARTIFACTORY_API_TOKEN=${ARTIFACTORY_API_TOKEN:-`vault kv get -field key dx_cja_arrow/arrowops_artifactory`}
echo ${ARTIFACTORY_API_TOKEN} > artifactory_api_token
cleanup() {
rm -rf secret_*
rm -rf artifactory_*
}
trap "cleanup" EXIT
IMG="ballista:${VERSION}"
docker build $DOCKER_BUILD_OPTIONS \
--progress=plain \
--secret id=artifactory_user,src=./artifactory_user \
--secret id=artifactory_api_token,src=./artifactory_api_token \
-t ${IMG} .
if [[ $? -eq 0 ]]; then
docker tag ${IMG} ${IMAGE_REPO_ADDRESS}/${IMG}
# if we have NOPUSH, don't push and don't delete local images
[[ -z "$NOPUSH" ]] && {
docker push ${IMAGE_REPO_ADDRESS}/${IMG}
docker images --format "{{.Repository}}:{{.Tag}} {{.ID}}" | grep ".\+/${IMG}" | awk '{print $1}' | xargs docker rmi -f
}
docker rmi -f ${IMG}
else
echo "Docker build failed! See errors above."
exit 1
fi
exit 0