2024-07-22 11:36:01 +00:00
|
|
|
include config.mk
|
|
|
|
|
|
|
|
.DEFAULT_GOAL := all
|
|
|
|
|
|
|
|
# Disabled due to https://github.com/containers/buildah/issues/5581
|
|
|
|
#REPO_STAMP := push-stamp
|
|
|
|
#REPO_PATH := repo/
|
|
|
|
#REPO_STAMPS := $(addsuffix /${REPO_STAMP},${CONTAINERS})
|
|
|
|
#
|
|
|
|
#%/${REPO_STAMP}: %/${BUILD_ID_OUT}
|
|
|
|
# @mkdir -p ${REPO_PATH}
|
|
|
|
# buildah push \
|
|
|
|
# -f oci \
|
|
|
|
# --compression-format zstd \
|
|
|
|
# --compression-level 10 \
|
|
|
|
# $(shell cat $<) \
|
|
|
|
# oci:${REPO_PATH}:$*:latest
|
|
|
|
# touch $@
|
|
|
|
|
|
|
|
MANIFEST_FILE = ${IMAGE_DIR}/manifest.json
|
2024-10-14 09:12:07 +00:00
|
|
|
BUILD_INSTRUCTIONS = Containerfile
|
2024-07-22 11:36:01 +00:00
|
|
|
|
|
|
|
# Autogenerated lists
|
2024-10-14 09:12:07 +00:00
|
|
|
CONTAINERS := $(shell find ./ -name '${BUILD_INSTRUCTIONS}' -exec 'dirname' '{}' ';' | cut -d'/' -f2-)
|
2024-07-22 11:36:01 +00:00
|
|
|
IMAGE_DIRS := $(addsuffix /${IMAGE_DIR},${CONTAINERS})
|
|
|
|
BUILD_IDS := $(addsuffix /${BUILD_ID_OUT},${CONTAINERS})
|
|
|
|
BUILD_LOGS := $(addsuffix /${BUILD_LOG},${CONTAINERS})
|
|
|
|
MANIFESTS := $(addsuffix /${MANIFEST_FILE},${CONTAINERS})
|
|
|
|
|
|
|
|
# Make workaround
|
|
|
|
# Inserting literal commas into function calls without interpreting them as delimiters
|
|
|
|
, := ,
|
|
|
|
|
|
|
|
# Build all containers in order by default
|
|
|
|
all: unified
|
|
|
|
|
|
|
|
unified: $(MANIFESTS) # $(REPO_STAMPS)
|
|
|
|
localbuild: $(BUILD_IDS)
|
|
|
|
|
|
|
|
# Build process
|
|
|
|
%/${MANIFEST_FILE}: %/${BUILD_ID_OUT}
|
|
|
|
@mkdir -p $*/${IMAGE_DIR}
|
|
|
|
buildah push \
|
|
|
|
-f oci \
|
|
|
|
$(shell cat $<) \
|
|
|
|
dir:$*/${IMAGE_DIR}
|
|
|
|
|
2024-10-14 09:12:07 +00:00
|
|
|
%/${BUILD_ID_OUT}: %/${BUILD_INSTRUCTIONS}
|
2024-07-22 11:36:01 +00:00
|
|
|
buildah build \
|
|
|
|
--jobs 0 \
|
|
|
|
--network=none \
|
|
|
|
--logfile=$*/${BUILD_LOG} \
|
|
|
|
-t $*:latest \
|
|
|
|
--iidfile $@ \
|
|
|
|
$(foreach secretpath,$(wildcard $*/secrets/*),\
|
|
|
|
--secret id=$(patsubst $*/secrets/%,%,${secretpath})$(,)src=${secretpath}) \
|
|
|
|
$*
|
|
|
|
|
|
|
|
# Clean up
|
2024-10-14 09:12:07 +00:00
|
|
|
clean: cleanbuild cleandirs cleanlogs
|
|
|
|
|
|
|
|
cleanlogs:
|
|
|
|
-rm -rv ${BUILD_LOGS}
|
2024-07-22 11:36:01 +00:00
|
|
|
|
|
|
|
cleanbuild:
|
|
|
|
-rm -rv ${BUILD_IDS}
|
|
|
|
|
|
|
|
cleandirs:
|
|
|
|
-rm -rv ${IMAGE_DIRS}
|
|
|
|
|
2024-10-14 09:12:07 +00:00
|
|
|
.PHONY: all clean cleanbuild cleandirs cleanlogs localbuild unified
|
2024-07-22 11:36:01 +00:00
|
|
|
.SUFFIXES:
|
|
|
|
|
|
|
|
# Somehow GNU make forgets these are intermediates if not explicitly stated, feel free to look into it *shrug*
|
|
|
|
.SECONDARY: $(BUILD_IDS)
|