hack: polish scripts (#133)
Signed-off-by: Ahmet Alp Balkan <ahmetb@google.com>
This commit is contained in:
parent
1d452f449a
commit
3da0ae3b31
4 changed files with 47 additions and 56 deletions
|
@ -1,3 +1,5 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
# Copyright 2019 Google LLC
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
|
@ -12,28 +14,28 @@
|
|||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
# Builds and pushes docker image for each demo microservice.
|
||||
# Builds and pushes docker image for each demo microservice.
|
||||
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
SCRIPTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||
|
||||
log() { echo "$1" >&2; }
|
||||
fail() { log "$1"; exit 1; }
|
||||
|
||||
TAG="${TAG?TAG env variable must be specified}"
|
||||
REPO_PREFIX="${REPO_PREFIX?REPO_PREFIX env variable must be specified}"
|
||||
|
||||
while IFS= read -d $'\0' -r dir; do
|
||||
# build image
|
||||
svcname="$(basename "${dir}")"
|
||||
image="${REPO_PREFIX}/$svcname:$TAG"
|
||||
(
|
||||
cd "${dir}"
|
||||
log "Building: ${image}"
|
||||
docker build -t "${image}" .
|
||||
|
||||
for dir in ./src/*/
|
||||
do
|
||||
# build image
|
||||
svcname="$(basename $dir)"
|
||||
image="$REPO_PREFIX/$svcname:$TAG"
|
||||
echo "Building and pushing $image..."
|
||||
docker build -t $image -f $dir/Dockerfile $dir
|
||||
log "Pushing: ${image}"
|
||||
docker push "${image}"
|
||||
)
|
||||
done < <(find "${SCRIPTDIR}/../src" -mindepth 1 -maxdepth 1 -type d -print0)
|
||||
|
||||
# push image
|
||||
docker push $image
|
||||
done
|
||||
|
||||
log "Successfully built and pushed images."
|
||||
log "Successfully built and pushed all images."
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue