Only build/tag/push images once

Signed-off-by: Rémy Coutable <remy@rymai.me>
This commit is contained in:
Rémy Coutable 2020-02-25 19:06:49 +01:00
parent cc680155e8
commit 611204c382
No known key found for this signature in database
GPG key ID: 98DFFD1C0C62B70B
4 changed files with 73 additions and 8 deletions

25
scripts/build-helpers.sh Normal file
View file

@ -0,0 +1,25 @@
function image_already_exists() {
image=$1
$(docker pull $image > /dev/null)
}
function build_if_needed() {
image=$1
if ! image_already_exists $image; then
docker build -t "$image" -f "Dockerfile.$image" .
else
echo "$image already exists, skipping build."
fi
}
function push_if_needed() {
image=$1
if ! image_already_exists $image; then
docker push "$image"
else
echo "$image already exists, skipping push."
fi
}