Repository navigation
Expand file tree
/
Copy pathMakefile
More file actions
85 lines (75 loc) · 2.12 KB
/
Copy pathMakefile
File metadata and controls
85 lines (75 loc) · 2.12 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
HOST ?= 127.0.0.1
PORT ?= 44020
LOCAL_ENCLAVE_DIR ?= /tmp/tvc-template-local-enclave
EPHEMERAL_FILE ?= $(LOCAL_ENCLAVE_DIR)/qos.ephemeral.key
QUORUM_FILE ?= $(LOCAL_ENCLAVE_DIR)/qos.quorum.key
.PHONY: all
all: build
.PHONY: build
build:
cargo build --all
.PHONY: test
test: build
cargo test --all-targets
.PHONY: fmt
fmt:
cargo fmt
.PHONY: lint
lint:
cargo clippy --version
cargo clippy --all-targets -- -D warnings
# Generate keys to simulate QOS control.
.PHONY: local-keys
local-keys:
mkdir -p $(LOCAL_ENCLAVE_DIR)
test -f $(EPHEMERAL_FILE) || openssl rand -hex 32 > $(EPHEMERAL_FILE)
test -f $(QUORUM_FILE) || openssl rand -hex 32 > $(QUORUM_FILE)
.PHONY: run
run: local-keys
cargo run --bin helloworld -- \
--host $(HOST) \
--port $(PORT) \
--ephemeral-file $(EPHEMERAL_FILE) \
--quorum-file $(QUORUM_FILE)
out/helloworld/index.json: \
Cargo.lock Cargo.toml rust-toolchain.toml $(shell find images/helloworld crates -type f ! -path '*/target/*')
$(call build,helloworld)
define build_context
$$( \
mkdir -p out; \
self=$(1); \
for each in $$(find out/ -maxdepth 2 -name index.json); do \
package=$$(basename $$(dirname $${each})); \
if [ "$${package}" = "$${self}" ]; then continue; fi; \
printf -- ' --build-context %s=oci-layout://./out/%s' "$${package}" "$${package}"; \
done; \
)
endef
,:=,
define build
$(eval NAME := $(1))
$(eval TYPE := $(if $(2),$(2),dir))
$(eval REGISTRY := tkhq-tvc-helloworld)
$(eval PLATFORM := linux/amd64)
DOCKER_BUILDKIT=1 \
SOURCE_DATE_EPOCH=1 \
BUILDKIT_MULTIPLATFORM=1 \
docker build \
--build-arg VERSION=$(VERSION) \
--tag $(REGISTRY)/$(NAME) \
--progress=plain \
--platform=$(PLATFORM) \
--label "org.opencontainers.image.source=https://github.com/tkhq/tvc-helloworld" \
$(if $(filter common,$(NAME)),,$(call build_context,$(1))) \
$(if $(filter 1,$(NOCACHE)),--no-cache) \
--output "\
type=oci,\
$(if $(filter dir,$(TYPE)),tar=false$(,)) \
rewrite-timestamp=true,\
force-compression=true,\
name=$(NAME),\
$(if $(filter tar,$(TYPE)),dest=$@") \
$(if $(filter dir,$(TYPE)),dest=out/$(NAME)") \
-f images/$(NAME)/Containerfile \
.
endef