Repository navigation
Expand file tree
/
Copy pathMakefile
More file actions
97 lines (78 loc) · 2.63 KB
/
Copy pathMakefile
File metadata and controls
97 lines (78 loc) · 2.63 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
.DEFAULT_GOAL := help
# Image configuration
IMAGE_NAME := comses/netlogo
NETLOGO_VERSION ?= 7.0.4
IMAGE_TAG := $(IMAGE_NAME):$(NETLOGO_VERSION)
IMAGE_LATEST := $(IMAGE_NAME):latest
# GHCR configuration
REGISTRY ?= ghcr.io
GHCR_IMAGE := $(REGISTRY)/comses/netlogo
GHCR_TAG := $(GHCR_IMAGE):$(NETLOGO_VERSION)
GHCR_LATEST := $(GHCR_IMAGE):latest
# Docker build arguments
DOCKER ?= docker
DOCKERFILE := Dockerfile
BUILD_CONTEXT := .
# Colors for help output
COLOR_RESET := \033[0m
COLOR_BOLD := \033[1m
COLOR_CYAN := \033[36m
##@ Help
.PHONY: help
help: ## Display this help message
@awk 'BEGIN { \
printf "Usage: make $(COLOR_BOLD)<target>$(COLOR_RESET)\n\n"; \
printf "$(COLOR_CYAN)Targets:$(COLOR_RESET)\n"; \
} \
/^##@/ { \
sub(/^##@[[:space:]]*/, "", $$0); \
printf "\n$(COLOR_BOLD)%s$(COLOR_RESET)\n", $$0; \
next; \
} \
/^[a-zA-Z_-]+:.*##/ { \
sub(/:.*/, "", $$0); \
sub(/##[[:space:]]*/, " ", $$0); \
printf " %-20s %s\n", $$1, substr($$0, length($$1)+4); \
}' $(MAKEFILE_LIST)
##@ Build
.PHONY: build
build: ## Build the NetLogo Docker image
$(DOCKER) build \
--build-arg NETLOGO_VERSION=$(NETLOGO_VERSION) \
-t $(IMAGE_TAG) \
-f $(DOCKERFILE) \
$(BUILD_CONTEXT)
.PHONY: tag-latest
tag-latest: build ## Tag the built image as latest
$(DOCKER) tag $(IMAGE_TAG) $(IMAGE_LATEST)
##@ Publish
.PHONY: tag-ghcr
tag-ghcr: build ## Tag the built image for GHCR (version and latest)
$(DOCKER) tag $(IMAGE_TAG) $(GHCR_TAG)
$(DOCKER) tag $(IMAGE_TAG) $(GHCR_LATEST)
.PHONY: push-ghcr
push-ghcr: tag-ghcr ## Push the image to GHCR (requires docker login ghcr.io)
$(DOCKER) push $(GHCR_TAG)
$(DOCKER) push $(GHCR_LATEST)
##@ Validation
.PHONY: validate
validate: build ## Build the image and run a validation smoke test
$(MAKE) --no-print-directory smoke-test
.PHONY: smoke-test
smoke-test: ## Run a headless NetLogo model to verify the image works
@echo "Running NetLogo headless smoke test..."
@$(DOCKER) run --rm -v $(CURDIR)/examples:/opt/examples:ro $(IMAGE_TAG) \
--model /opt/examples/wolf-sheep-sd.nlogox \
--experiment "smoke test" \
--table -
@echo "Smoke test passed."
.PHONY: check-checksum
check-checksum: ## Verify the NetLogo tarball checksum matches the expected value
cd checksums && sha256sum --check --strict NetLogo-$(NETLOGO_VERSION)-64.tgz.sha256
##@ Cleanup
.PHONY: clean
clean: ## Remove dangling images from the build cache
$(DOCKER) image prune -f --filter "label=org.opencontainers.image.title=$(IMAGE_NAME)"
.PHONY: distclean
distclean: clean ## Remove all built images for this project
-$(DOCKER) rmi -f $(IMAGE_TAG) $(IMAGE_LATEST) $(GHCR_TAG) $(GHCR_LATEST)