52 lines
1.3 KiB
Makefile
52 lines
1.3 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)
|
|
import: $(addsuffix /import,${IMAGES})
|
|
|
|
# Build process
|
|
%/${IMAGE_OUTPUT}: %/${BUILD_ID_OUT}
|
|
buildah push \
|
|
-f oci \
|
|
$(shell cat $<) \
|
|
oci-archive:$@:${DOMAIN}/$*:$(shell date +%s)
|
|
|
|
%/${IMAGE_OUTPUT}/import: %/${IMAGE_OUTPUT}
|
|
buildah pull \
|
|
oci-archive:$<
|
|
|
|
%/${BUILD_ID_OUT}: %/Containerfile
|
|
buildah build \
|
|
--jobs 0 \
|
|
--network=none \
|
|
--layers=true \
|
|
-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 import
|
|
.SUFFIXES:
|
|
|
|
# Somehow GNU make forgets these are intermediates if not explicitly stated, feel free to look into it *shrug*
|
|
.SECONDARY: $(BUILD_IDS)
|