-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
42 lines (32 loc) · 1.27 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
# include .env file and export its env vars
# (-include to ignore error if it does not exist)
-include .env
.PHONY: build clean publish test
# Variables
CARGO_NAME=switchboard-function # Cargo.toml name
DOCKER_IMAGE_NAME=switchboardlabs/my-function # Docker registry image name
check_docker_env:
ifeq ($(strip $(DOCKER_IMAGE_NAME)),)
$(error DOCKER_IMAGE_NAME is not set)
else
@echo DOCKER_IMAGE_NAME: ${DOCKER_IMAGE_NAME}
endif
DOCKER_BUILD_COMMAND=DOCKER_BUILDKIT=1 docker buildx build --platform linux/amd64 --build-arg CARGO_NAME=${CARGO_NAME}
# Default make task
all: build
docker_build: check_docker_env
${DOCKER_BUILD_COMMAND} --pull -f Dockerfile -t ${DOCKER_IMAGE_NAME} --load ./
docker_publish: check_docker_env
${DOCKER_BUILD_COMMAND} --pull -f Dockerfile -t ${DOCKER_IMAGE_NAME} --push ./
build: docker_build measurement
publish: docker_publish measurement
measurement: check_docker_env
@docker run -d --platform=linux/amd64 -q --name=my-switchboard-function ${DOCKER_IMAGE_NAME}:latest
@docker cp my-switchboard-function:/measurement.txt ./measurement.txt
@echo -n 'MrEnclve: '
@cat measurement.txt
@docker stop my-switchboard-function > /dev/null
@docker rm my-switchboard-function > /dev/null
# Task to clean up the compiled rust application
clean:
cargo clean