Build makes sure that images are rebuilt after change of docker defs
parent
a3beb7ccf6
commit
baff6b5e3c
8
Makefile
8
Makefile
|
@ -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
|
||||
|
|
|
@ -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
|
Loading…
Reference in New Issue