Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 19 additions & 13 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,10 +1,20 @@
.SUFFIXES:

# Use bash if available, otherwise fall back to default shell
SHELL := $(shell which bash 2>/dev/null || echo /bin/sh)

# Find all directories containing metadata.hcl
FILES := $(shell find . -type f -name metadata.hcl)
DIRS := $(patsubst %/,%,$(patsubst ./%,%,$(dir $(FILES))))

.PHONY: all clean check prereqs $(DIRS)
ifeq ($(DIRS),)
$(error No subdirectories with metadata.hcl files found)
endif

# Create push targets for each directory
PUSH_TARGETS := $(addprefix push-,$(DIRS))

.PHONY: all check prereqs push $(DIRS) $(PUSH_TARGETS)

# Colours
GREEN := \033[0;32m
Expand All @@ -15,6 +25,8 @@ NC := \033[0m
# Dry run flag
DRY_RUN ?= false

default: all

# --------------------------
# Prerequisite checks
# --------------------------
Expand All @@ -32,29 +44,23 @@ prereqs:
check: prereqs
@echo -e "$(BLUE)Performing bake --check for all projects...$(NC)"
@$(foreach dir,$(DIRS), \
echo -e "$(BLUE)[CHECK] $dir$(NC)"; \
echo -e "$(BLUE)[CHECK] $(dir) $(NC)"; \
docker buildx bake -f $(dir)/metadata.hcl -f docker-bake.hcl --check; \
)

# --------------------------
# Push all images
# --------------------------
push: all
@echo -e "$(BLUE)Performing bake --push for all projects...$(NC)"
@$(foreach dir,$(DIRS), \
echo -e "$(BLUE)[PUSH] $dir$(NC)"; \
if [ "$(DRY_RUN)" = "true" ]; then \
echo -e "$(GREEN)[DRY RUN] docker buildx bake -f $(dir)/metadata.hcl -f docker-bake.hcl --push$(NC)"; \
else \
docker buildx bake -f $(dir)/metadata.hcl -f docker-bake.hcl --push; \
fi; \
)
push: prereqs $(PUSH_TARGETS)
@echo -e "$(GREEN)======================================================$(NC)"
@echo -e "$(GREEN)Push successful for all projects: $(DIRS)$(NC)"
@echo -e "$(GREEN)======================================================$(NC)"

# --------------------------
# Generic per-project push
# Usage: make push-<project>
# --------------------------
push-%: prereqs
$(PUSH_TARGETS): push-%: prereqs
@echo -e "$(BLUE)Performing bake --push for $*...$(NC)"
ifeq ($(DRY_RUN),true)
@echo -e "$(GREEN)[DRY RUN] docker buildx bake -f $*/metadata.hcl -f docker-bake.hcl --push$(NC)"
Expand Down