Skip to content

Instantly share code, notes, and snippets.

@k2wanko
Created October 14, 2015 08:52
Show Gist options
  • Save k2wanko/5ce46380afded67a6805 to your computer and use it in GitHub Desktop.
Save k2wanko/5ce46380afded67a6805 to your computer and use it in GitHub Desktop.
docker-build.sh
#!/bin/sh
remote=""
user=$(git remote -v | grep push | awk '{print $2}' | sed -e "s/.*:\(.*\)\/.*/\1/")
repository=$(git remote -v | grep push | awk '{print $2}' | sed -e "s/.*docker-\(.*\)\..*/\1/")
target=$user/$repository
if [ -n "$remote" ];then
target=$remote/$target
fi
root=$(pwd)
for f in $(find . -follow -name "Dockerfile"); do
cd $(dirname $f)
tag=$(echo $f | sed -e "s/\.\/\(.*\)\/.*/\1/")
docker build -t $target:$tag .
cd $root
done
docker push $target
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment