diff --git a/Makefile b/Makefile new file mode 100755 index 0000000..1e33c1b --- /dev/null +++ b/Makefile @@ -0,0 +1,54 @@ +TARGETS := $(patsubst ./%/,%,$(dir $(shell find -L . -maxdepth 2 -mindepth 2 -type f -and -name Makefile))) +.PHONY: all +all: login $(TARGETS) + +include config.mk +$(foreach target,$(TARGETS),$(eval include $(target)/Makefile)) + +container_image_name = $(REGISTRY_DOMAIN)/$(REGISTRY_USER)/$(CONTAINER_NAME_PREFIX)$(target) +app_version = $(shell head -n 1 $(target)/version) +remove_last_version_part = $(shell a="$(1)"; [ "$(1)" = "$${a%.*}" ] && echo "" || echo "$${a%.*}") +all_versions = $(if $(1),$(1) $(call all_versions,$(call remove_last_version_part,$(1)))) +tag_alpine_version_parts := alpine $(addprefix alpine,$(call all_versions,$(ALPINE_VERSION))) +tag_app_version_parts = $(call all_versions,$(app_version)) +tags = $(tag_app_version_parts) $(tag_alpine_version_parts)\ + $(foreach app_part,$(tag_app_version_parts),$(addprefix $(app_part)-,$(tag_alpine_version_parts))) + +define build_rule = +.PHONY: build_$(target) +build_$(target): + podman build \ + -t $(container_image_name):latest \ + --build-arg "ALPINE_VERSION=$(ALPINE_VERSION)" \ + --build-arg "VERSION=$(app_version)" \ + $(target) +endef + +define tag_rule = +.PHONY: tag_$(target) +tag_$(target): + podman tag $(container_image_name):latest $(addprefix $(container_image_name):,$(tags)) +endef + +define push_rule = +.PHONY: push_$(target) +push_$(target): login + podman push "$(container_image_name):latest" + $(foreach tag,$(tags),podman push $(container_image_name):$(tag);) +endef + +define target_rule = +.PHONY: $(target) +$(target): prepare_$(target) build_$(target) tag_$(target) push_$(target) +endef + +.PHONY: login +login: + podman login $(REGISTRY_DOMAIN) + +$(foreach target,$(TARGETS),$(eval $(target_rule))) +$(foreach target,$(TARGETS),$(eval $(build_rule))) +$(foreach target,$(TARGETS),$(eval $(tag_rule))) +$(foreach target,$(TARGETS),$(eval $(push_rule))) + +clean: $(foreach target,$(TARGETS),clean_$(target)) diff --git a/agate/Makefile b/agate/Makefile new file mode 100644 index 0000000..481bfc9 --- /dev/null +++ b/agate/Makefile @@ -0,0 +1,7 @@ +.PHONY: prepare_agate +prepare_agate: + @echo Nothing to do + +.PHONY: clean_agate +clean_agate: + @echo Nothing to do diff --git a/alpine-version b/alpine-version deleted file mode 100644 index 0f4de9d..0000000 --- a/alpine-version +++ /dev/null @@ -1 +0,0 @@ -3.23 diff --git a/build_and_push.sh b/build_and_push.sh deleted file mode 100755 index e1da529..0000000 --- a/build_and_push.sh +++ /dev/null @@ -1,54 +0,0 @@ -#!/bin/sh -e - -REGISTRY_DOMAIN="${REGISTRY_DOMAIN:-git.joeac.net}" -REGISTRY_USER="${REGISTRY_USER:-joeac}" -ARCHITECTURE="$(lscpu | grep ^Architecture: | sed "s/Architecture:[[:space:]]*//")" -CONTAINER_NAME_PREFIX="${CONTAINER_NAME_PREFIX:-$([ "armv7" = $(echo "$ARCHITECTURE" | cut -c1-5) ] && echo "armv7/" || echo "")}" -ALPINE_VERSION="${ALPINE_VERSION:-$(head -n 1 alpine-version)}" -CONTAINER_PATTERN="${CONTAINER_PATTERN:-${1:-*}}" - -for container in ${CONTAINER_PATTERN} -do - if ( ! [ -d "$container" ] ) || ( ! [ -f "${container}/Dockerfile" ] ) - then - continue - fi - - container_image_name="${REGISTRY_DOMAIN}/${REGISTRY_USER}/${CONTAINER_NAME_PREFIX}${container}" - app_version="$(head -n 1 "${container}/version")" - podman build \ - -t "${container_image_name}:latest" \ - --build-arg "ALPINE_VERSION=${ALPINE_VERSION}" \ - --build-arg "VERSION=${app_version}" \ - "$container" - - podman image tag "${container_image_name}:latest" "${container_image_name}:alpine" - podman push "${container_image_name}:alpine" - alpine_version_part="${ALPINE_VERSION}" - while true - do - app_version_part="${app_version}" - while true - do - podman image tag "${container_image_name}:latest" "${container_image_name}:${app_version_part}-alpine${alpine_version_part}" - podman push "${container_image_name}:${app_version_part}-alpine${alpine_version_part}" - if [ "${app_version_part}" = ${app_version_part%.*} ] - then - break - else - app_version_part=${app_version_part%.*} - fi - done - podman image tag "${container_image_name}:latest" "${container_image_name}:alpine${alpine_version_part}" - podman push "${container_image_name}:alpine${alpine_version_part}" - if [ -z "${alpine_version_part}" ] - then - break - elif [ "${alpine_version_part}" = ${alpine_version_part%.*} ] - then - alpine_version_part="" - else - alpine_version_part=${alpine_version_part%.*} - fi - done -done diff --git a/comitium/Makefile b/comitium/Makefile new file mode 100644 index 0000000..78076f5 --- /dev/null +++ b/comitium/Makefile @@ -0,0 +1,7 @@ +.PHONY: prepare_comitium +prepare_comitium: + @echo Nothing to do + +.PHONY: clean_comitium +clean_comitium: + @echo Nothing to do diff --git a/config.mk b/config.mk new file mode 100644 index 0000000..536f8a2 --- /dev/null +++ b/config.mk @@ -0,0 +1,5 @@ +REGISTRY_DOMAIN := git.joeac.net +REGISTRY_USER := joeac +ARCHITECTURE := $(shell lscpu | grep ^Architecture: | sed "s/Architecture:[[:space:]]*//") +CONTAINER_NAME_PREFIX := $(if $(filter armv7%,$(ARCHITECTURE)),armv7/) +ALPINE_VERSION := 3.23 diff --git a/crond/Makefile b/crond/Makefile new file mode 100644 index 0000000..6bf1f48 --- /dev/null +++ b/crond/Makefile @@ -0,0 +1,7 @@ +.PHONY: prepare_crond +prepare_crond: + @echo Nothing to do + +.PHONY: clean_crond +clean_crond: + @echo Nothing to do diff --git a/msmtp/Makefile b/msmtp/Makefile new file mode 100644 index 0000000..2ac9b0a --- /dev/null +++ b/msmtp/Makefile @@ -0,0 +1,7 @@ +.PHONY: prepare_msmtp +prepare_msmtp: + @echo Nothing to do + +.PHONY: clean_msmtp +clean_msmtp: + @echo Nothing to do