Build and tagging all the services - GlueScript/Glue GitHub Wiki
#!/bin/bash
set -o pipefail
owner=timrodger
# build all containers
containers=
cat $(dirname )/services``
for c in $containers
do
name=$owner/$c
`cd $c/src`
`# do not build if test returns error`
`npm test || exit 2`
`cd ../ `
`# tag container with most recent git tag of source `
`# use $owner/$c:most recent tag - head commit`
`tag=$(git tag -l | tail -n1)-$(git log --oneline | head -n1 | awk '{print }')`
`echo building ${name}:${tag}`
`docker build -t ${name}:${tag} . | tee build.log || exit 1`
`ID=$(tail -1 build.log | awk '{print ;}')`
`docker tag $ID ${name}:latest`
`rm build.log`
`cd ../ `
done