Add Makefile for multi-platform Docker build and publish

This commit is contained in:
Kili 2025-12-25 21:33:43 +01:00
parent d2e3810d3c
commit 04d87e8e8e

41
Makefile Normal file
View File

@ -0,0 +1,41 @@
# Multi-platform Docker build and publish for CyberChef
IMAGE_NAME ?= ghcr.io/gchq/cyberchef
PLATFORMS ?= linux/amd64,linux/arm64
MONTHLY_TAG ?= $(shell date +%Y-%m)
.PHONY: check-branch build publish scan
check-branch:
@current=$$(git rev-parse --abbrev-ref HEAD); \
if [ "$$current" != "main" ]; then \
echo "Builds must run from the main branch (current: $$current)"; \
exit 1; \
fi
build: check-branch
docker buildx build \
--pull \
--platform $(PLATFORMS) \
--tag $(IMAGE_NAME):latest \
--tag $(IMAGE_NAME):$(MONTHLY_TAG) \
--sbom=true \
--provenance=true \
--output=type=docker \
.
publish: check-branch
docker buildx build \
--pull \
--platform $(PLATFORMS) \
--tag $(IMAGE_NAME):latest \
--tag $(IMAGE_NAME):$(MONTHLY_TAG) \
--sbom=true \
--provenance=true \
--push \
.
$(MAKE) scan
scan:
docker scout cves $(IMAGE_NAME):latest --only-severity critical,high || true
@echo "⚠️ Review High/Critical vulnerability findings above."