chore(build): script to build and push docker images.

This commit is contained in:
Rajesh Rajendran 2021-05-14 22:14:36 +05:30
parent 91cbd593b8
commit 409d071aac
No known key found for this signature in database
GPG key ID: F9F6FCAB8BACB638
3 changed files with 25 additions and 0 deletions

View file

@ -25,6 +25,9 @@ function build_api(){
envarg="default-ee"
}
docker build -f ./Dockerfile --build-arg envarg=$envarg -t ${DOCKER_REPO:-'local'}/chalice:${git_sha1} .
[[ $PUSH_IMAGE -eq 1 ]] && {
docker push ${DOCKER_REPO:-'local'}/chalice:${git_sha1}
}
}
check_prereq

View file

@ -27,11 +27,17 @@ function build_api(){
[[ $2 != "" ]] && {
image="$2"
docker build -t ${DOCKER_REPO:-'local'}/$image:${git_sha1} --build-arg SERVICE_NAME=$image .
[[ $PUSH_IMAGE -eq 1 ]] && {
docker push ${DOCKER_REPO:-'local'}/$image:${git_sha1}
}
return
}
for image in $(ls services);
do
docker build -t ${DOCKER_REPO:-'local'}/$image:${git_sha1} --build-arg SERVICE_NAME=$image .
[[ $PUSH_IMAGE -eq 1 ]] && {
docker push ${DOCKER_REPO:-'local'}/$image:${git_sha1}
}
echo "::set-output name=image::${DOCKER_REPO:-'local'}/$image:${git_sha1}"
done
}

View file

@ -0,0 +1,16 @@
#!/bin/bash
set -e
# This script will build and push docker image to registry
echo $DOCKER_REPO
[[ -z DOCKER_REPO ]] && {
echo Set DOCKER_REPO="your docker registry"
exit 1
} || {
docker login $DOCKER_REPO
cd ../../api
PUSH_IMAGE=1 bash build.sh
cd ../backend
PUSH_IMAGE=1 bash build.sh
}