-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
51 lines (42 loc) · 1.43 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
51
ROOT_DIR?=$(abspath $(dir $(lastword $(MAKEFILE_LIST))))
PREDICTORS_DIR=$(ROOT_DIR)/predictors
include .env
# Please define GCP_PROJECT in .env file
# echo 'GCP_PROJECT=<PLEASE WRITE YOUR GCP PROJECT NAME HERE>' > .env
GCP_REGION?=us-central1
GCP_SERVICE_ACCOUNT?=numerai-compute@$(GCP_PROJECT).iam.gserviceaccount.com
CLOUD_RUN_CPU?=2
CLOUD_RUN_MEMORY?=2Gi
REPOSITORY?=$(GCP_REGION)-docker.pkg.dev/$(GCP_PROJECT)/numerai-compute
TAG?=$(shell date '+%Y%m%d')
run-%: build-%
docker run --rm -it \
-e PORT=8080 \
-p 8080:8080 \
$(REPOSITORY)/${@:run-%=%}:local
build-%:
docker build \
--tag $(REPOSITORY)/${@:build-%=%}:$(TAG) \
--platform linux/amd64 \
-f $(PREDICTORS_DIR)/${@:build-%=%}/Dockerfile \
--build-arg PREDICTOR=${@:build-%=%} \
$(ROOT_DIR)
docker tag $(REPOSITORY)/${@:build-%=%}:$(TAG) $(REPOSITORY)/${@:build-%=%}:local
push-%:
docker push $(REPOSITORY)/${@:push-%=%}:$(TAG)
deploy-%:
gcloud beta run deploy numerai-compute-$(subst _,-,${@:deploy-%=%}) \
--execution-environment=gen2 \
--image=$(REPOSITORY)/${@:deploy-%=%}:$(TAG) \
--allow-unauthenticated \
--service-account=$(GCP_SERVICE_ACCOUNT) \
--concurrency=1 \
--timeout=1200 \
--cpu=$(CLOUD_RUN_CPU) \
--memory=$(CLOUD_RUN_MEMORY) \
--max-instances=4 \
--set-secrets=NUMERAI_PUBLIC_ID=numerai-public-id:1,NUMERAI_SECRET_KEY=numerai-secret:1 \
--region=$(GCP_REGION) \
--project=$(GCP_PROJECT)
release-%: build-% push-% deploy-%
true