Containers/Makefile

43 lines
1.1 KiB
Makefile

include config.mk
.DEFAULT_GOAL := all
# Autogenerated lists
CONTAINERS := $(shell find ./ -name 'Containerfile' -exec 'dirname' '{}' ';' | cut -d'/' -f2-)
IMAGES := $(addsuffix /${IMAGE_OUTPUT},${CONTAINERS})
BUILD_IDS := $(addsuffix /${BUILD_ID_OUT},${CONTAINERS})
# Make workaround
# Inserting literal commas into function calls without interpreting them as delimiters
, := ,
# Build all containers in order by default
all: oci
oci: $(IMAGES)
localbuild: $(BUILD_IDS)
# Build process
%/${IMAGE_OUTPUT}: %/${BUILD_ID_OUT}
buildah push -f oci \
$(shell cat $<) \
oci-archive:$@:${DOMAIN}/$*:latest
%/${BUILD_ID_OUT}: %/Containerfile
buildah build \
-t ${DOMAIN}/$*:latest \
--iidfile $*/${BUILD_ID_OUT} \
$(foreach secretpath,$(wildcard $*/secrets/*),\
--secret id=$(patsubst $*/secrets/%,%,${secretpath})$(,)src=${secretpath}) \
$*
# Clean up
clean:
-rm -rv ${IMAGES} ${BUILD_IDS}
.PHONY: all localbuild oci clean
.SUFFIXES:
# Somehow GNU make forgets these are intermediates if not explicitly stated, feel free to look into it *shrug*
.SECONDARY: $(BUILD_IDS)