docker-builder/Makefile

46 lines
1.8 KiB
Makefile

define INC_DOCKER =
1
endef
$(info Defined INC_DOCKER)
docker_src = /devel/docker
include ${docker_src}/docker_vars.sh
export
# A container is built based on a given Dockerfile.
# We mark a sentinel when a container is built.
${docker_src}/built/%.sentinel: ${docker_src}/%.dockerfile
mkdir -p $(dir $@);
grep -e '^FROM' $< | awk '{print $$2}' \
| tr : _ | xargs -I{} $(MAKE) ${docker_src}/built/{}.sentinel;
cd ${docker_src}; docker build -f $< --tag $* . && touch $@
# Exceptions to this rule are listed below, but should handle the rule
# the same ways.
${docker_src}/built/debian_%.sentinel:
docker pull "debian:$*" && touch $@;
# For example, the main openwrt builder container is built specific to
# a remote and a commit. [Basing this container on a main
# openwrt-builder container still saves us time as OpenWrt reomtes
# reliably share almost all of the same history.]
##
# Two formats are accepted: openwrt-builder-${rev}.sentinel for the
# base builder on the default remote at a particular revision, and
# openwrt-builder-${remote}_${rev}.sentinel to construct the builder
# pointing to a particular remote at a particular revision.
${docker_src}/built/openwrt-builder-%.sentinel: \
${docker_src}/openwrt-builder-commit.dockerfile \
${docker_src}/built/openwrt-builder.sentinel \
${docker_src}/openwrt-remotes.txt
rev=$*; \
if [ "$$rev" != "$${rev%_*}" ]; then \
remote=$(shell echo $* | cut -d_ -f1); \
commit=$(shell echo $* | cut -d_ -f2); \
remoteurl=$(shell echo $* | cut -d_ -f1 | xargs -I{} grep -e "^{}" ${docker_src}/openwrt-remotes.txt | cut -d ' ' -f2); \
docker build -f $< --build-arg=remote="$$remote" --build-arg=commit="$$commit" --build-arg=remoteurl="$$remoteurl" --tag openwrt-builder-$* .; \
else \
commit=$(shell echo $*); \
docker build -f $< --build-arg=commit="$$commit" --tag openwrt-builder-$* . ; \
fi && touch $@;