1
+ # Image names and tags
2
+ REGISTRY ?= ghcr.io
3
+ OWNER ?= bacalhau-project
4
+ PREFIX ?= wasm-sensors
5
+ PROXY_IMAGE ?= $(PREFIX ) -sqs-proxy
6
+ PULLER_IMAGE ?= $(PREFIX ) -sqs-puller
7
+ VERSION ?= $(shell date +% y.% m)
8
+
9
+ # Full image names
10
+ PROXY_FULL_NAME = $(REGISTRY ) /$(OWNER ) /$(PROXY_IMAGE )
11
+ PULLER_FULL_NAME = $(REGISTRY ) /$(OWNER ) /$(PULLER_IMAGE )
12
+
13
+ SHELL := /bin/bash
14
+
15
+ .PHONY : all build push clean login help
16
+
17
+ all : build
18
+
19
+ # #@ General
20
+
21
+ .PHONY : help
22
+ help : # # Display this help.
23
+ @awk ' BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m<target>\033[0m\n"} /^[a-zA-Z_0-9-]+:.*?##/ { printf " \033[36m%-15s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST )
24
+
25
+ # #@ Build
26
+
27
+ build : build-docker build-wasm
28
+
29
+ build-docker : build-proxy build-puller
30
+
31
+ build-proxy : # # Build the proxy Docker image for local architecture
32
+ docker buildx build \
33
+ -t $(PROXY_FULL_NAME ) :$(VERSION ) \
34
+ -t $(PROXY_FULL_NAME ) :latest \
35
+ --load \
36
+ -f containers/docker/sqs-proxy/Dockerfile containers/docker/sqs-proxy
37
+
38
+ build-puller : # # Build the puller Docker image for local architecture
39
+ docker buildx build \
40
+ -t $(PULLER_FULL_NAME ) :$(VERSION ) \
41
+ -t $(PULLER_FULL_NAME ) :latest \
42
+ --load \
43
+ -f containers/docker/sqs-puller/Dockerfile containers/docker/sqs-puller
44
+
45
+ # #@ Push
46
+
47
+ push : push-docker
48
+
49
+ push-docker : push-proxy push-puller
50
+
51
+ push-proxy : # # Push the proxy Docker image for all architectures
52
+ docker buildx build --platform linux/amd64,linux/arm64 \
53
+ -t $(PROXY_FULL_NAME ) :$(VERSION ) \
54
+ -t $(PROXY_FULL_NAME ) :latest \
55
+ --push \
56
+ -f containers/docker/sqs-proxy/Dockerfile containers/docker/sqs-proxy
57
+
58
+ push-puller : # # Push the puller Docker image for all architectures
59
+ docker buildx build --platform linux/amd64,linux/arm64 \
60
+ -t $(PULLER_FULL_NAME ) :$(VERSION ) \
61
+ -t $(PULLER_FULL_NAME ) :latest \
62
+ --push \
63
+ -f containers/docker/sqs-puller/Dockerfile containers/docker/sqs-puller
64
+
65
+
66
+ # #@ WASM
67
+
68
+ build-wasm : build-sqs-publisher build-config-updater build-config-reader build-dir-lister
69
+ build-sqs-publisher : # # Build the SQS publisher WASM module
70
+ @echo " Building SQS publisher WASM module..."
71
+ @cd containers/wasm/sqs-publisher && tinygo build -o ../../../network/modules/publisher.wasm -target wasi .
72
+ @echo " SQS publisher WASM build completed successfully!"
73
+
74
+ build-config-updater : # # Build the config updater WASM module
75
+ @echo " Building config updater WASM module..."
76
+ @cd containers/wasm/config-updater && tinygo build -o ../../../network/modules/config-updater.wasm -target wasi .
77
+ @echo " Config updater WASM build completed successfully!"
78
+
79
+ build-config-reader : # # Build the config reader WASM module
80
+ @echo " Building config reader WASM module..."
81
+ @cd containers/wasm/config-reader && tinygo build -o ../../../network/modules/config-reader.wasm -target wasi .
82
+ @echo " Config reader WASM build completed successfully!"
83
+
84
+ build-dir-lister : # # Build the directory lister WASM module
85
+ @echo " Building directory lister WASM module..."
86
+ @cd containers/wasm/dir-lister && tinygo build -o ../../../network/modules/dir-lister.wasm -target wasi .
87
+ @echo " Directory lister WASM build completed successfully!"
88
+
89
+ # #@ Development
90
+
91
+ .PHONY : login
92
+ login : # # Login to GitHub Container Registry
93
+ @echo " Logging into GitHub Container Registry..."
94
+ @if [ -z " ${GITHUB_PAT} " ]; then \
95
+ echo " Error: GITHUB_PAT environment variable is not set" ; \
96
+ exit 1; \
97
+ fi
98
+ @if [ -z " ${GITHUB_USERNAME} " ]; then \
99
+ echo " Error: GITHUB_USERNAME environment variable is not set" ; \
100
+ exit 1; \
101
+ fi
102
+ @echo " ${GITHUB_PAT} " | docker login ${REGISTRY} -u ${GITHUB_USERNAME} --password-stdin
103
+
104
+ # #@ Cleanup
105
+
106
+ clean : # # Clean up (no-op for now)
107
+ @echo " Clean target is currently a no-op"
108
+
109
+ # #@ Version
110
+
111
+ .PHONY : version
112
+ version : # # Output the current version
113
+ @echo ${VERSION}
0 commit comments