Build makes sure that images are rebuilt after change of docker defs

pull/77/head
Jakub Matys 2018-10-17 13:04:03 +02:00
parent a3beb7ccf6
commit baff6b5e3c
2 changed files with 34 additions and 2 deletions

View File

@ -43,15 +43,19 @@ build-images: clean-images
$(MAKE) .bin-image .deb-image
.bin-image:
@if [ -z "$(shell docker images --quiet --filter=reference=$(BIN_IMAGE):latest)" ]; then \
@if [ $$(build/tools/image_status.sh $(BIN_IMAGE):latest build/docker) != "ok" ]; then \
echo "Building image $(BIN_IMAGE)..."; \
docker build --no-cache=$(NO_CACHE) -t $(BIN_IMAGE) build/docker/bin; \
else \
echo "Image $(BIN_IMAGE) is up to date"; \
fi
.deb-image: .bin-image
@if [ -z "$(shell docker images --quiet --filter=reference=$(DEB_IMAGE):latest)" ]; then \
@if [ $$(build/tools/image_status.sh $(DEB_IMAGE):latest build/docker) != "ok" ]; then \
echo "Building image $(DEB_IMAGE)..."; \
docker build --no-cache=$(NO_CACHE) -t $(DEB_IMAGE) build/docker/deb; \
else \
echo "Image $(DEB_IMAGE) is up to date"; \
fi
clean: clean-bin clean-deb

View File

@ -0,0 +1,28 @@
#!/bin/bash
set -e
if [ $# -ne 2 ]; then
echo "Invalid parameters" 1>&2
exit 1
fi
IMG=$1
DIR=$2
IMG_CREATED_TIME=$(docker inspect --format='{{json .Metadata.LastTagTime}}' $IMG 2>/dev/null | tr -d '"')
if [ -z "$IMG_CREATED_TIME" ]; then
echo "missing"
exit 0
fi
IMG_CREATED_TS=$(date -d $IMG_CREATED_TIME +%s)
GIT_COMMIT_TS=$(date -d $(git log --pretty="format:%cI" -1 $DIR) +%s)
if [ $IMG_CREATED_TS -lt $GIT_COMMIT_TS ]; then
echo "out-of-time"
else
echo "ok"
fi
exit 0