-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
50 lines (40 loc) · 1.61 KB
/
Makefile
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
OS := $(shell uname | awk '{print tolower($$0)}')
ARCH := $(shell case $$(uname -m) in (x86_64) echo amd64 ;; (aarch64) echo arm64 ;; (*) echo $$(uname -m) ;; esac)
BIN_DIR := ./.bin
TINYGO_VERSION := 0.28.1
TINYGO := $(abspath $(BIN_DIR)/tinygo-$(TINYGO_VERSION))/bin/tinygo
DOCKER_NETWORK := proxy-wasm-google-metadata-identity-token_default
tinygo: $(TINYGO)
$(TINYGO):
@curl -sSL "https://github.com/tinygo-org/tinygo/releases/download/v$(TINYGO_VERSION)/tinygo$(TINYGO_VERSION).$(OS)-$(ARCH).tar.gz" | tar -C $(BIN_DIR) -xzv tinygo
@mv $(BIN_DIR)/tinygo $(BIN_DIR)/tinygo-$(TINYGO_VERSION)
.PHONY: test
test:
@cd ./test && go test -race -shuffle=on .
.PHONY: test-docker
test-docker:
docker compose stop
docker compose up --detach
docker run --rm --network $(DOCKER_NETWORK) jwilder/dockerize:0.6.1 -wait tcp://envoy:8080 -timeout 30s
docker run --rm --network $(DOCKER_NETWORK) jwilder/dockerize:0.6.1 -wait tcp://metadataserver:8080 -timeout 30s
docker run --rm --network $(DOCKER_NETWORK) jwilder/dockerize:0.6.1 -wait tcp://upstream:5000 -timeout 30s
docker run \
--rm \
--env ENVOY_ADDRESS=envoy:8080 \
--volume "$(shell pwd):/workspace" \
--workdir /workspace \
--network $(DOCKER_NETWORK) \
golang:1.20.5-bullseye make test
.PHONY: build
build: $(TINYGO)
@$(TINYGO) build -o $(BIN_DIR)/proxy-wasm-google-metadata-identity-token.wasm -scheduler=none -target=wasi .
.PHONY: build-docker
build-docker:
@docker run \
--rm \
--env XDG_CACHE_HOME=/tmp/.cache \
--volume "$(shell pwd):/workspace" \
--user "$(shell id -u):$(shell id -g)" \
--workdir /workspace \
golang:1.20.5-bullseye \
make build