commit 37a11cd32e3372880faf90d77c608128898ffc59 Author: Alex Denes Date: Mon Jul 22 11:36:01 2024 +0000 Squashed initial commit diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..fd367f4 --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +build_id +build_log +image/ +secrets/ diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..0923bfc --- /dev/null +++ b/Makefile @@ -0,0 +1,71 @@ +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 + +# Autogenerated lists +CONTAINERS := $(shell find ./ -name 'Containerfile' -exec 'dirname' '{}' ';' | cut -d'/' -f2-) +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} + +%/${BUILD_ID_OUT}: %/Containerfile + 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 +clean: cleanbuild cleandirs + +cleanbuild: + -rm -rv ${BUILD_IDS} + +cleandirs: + -rm -rv ${IMAGE_DIRS} + +.PHONY: all clean cleanbuild cleandirs localbuild unified +.SUFFIXES: + +# Somehow GNU make forgets these are intermediates if not explicitly stated, feel free to look into it *shrug* +.SECONDARY: $(BUILD_IDS) diff --git a/config.mk b/config.mk new file mode 100644 index 0000000..a73be69 --- /dev/null +++ b/config.mk @@ -0,0 +1,5 @@ +IMAGE_DIR := image +BUILD_ID_OUT := build_id +BUILD_LOG := build_log + +include */config.mk