-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMakefile
More file actions
116 lines (88 loc) · 2.59 KB
/
Makefile
File metadata and controls
116 lines (88 loc) · 2.59 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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
#======================#
# Install, clean, test #
#======================#
install_requirements:
@pip install -r requirements.txt
install:
@pip install . -U
clean:
@rm -f */version.txt
@rm -f .coverage
@rm -fr */__pycache__ */*.pyc __pycache__
@rm -fr build dist
@rm -fr proj-*.dist-info
@rm -fr proj.egg-info
test_structure:
@bash tests/test_structure.sh
#======================#
# API #
#======================#
run_api:
uvicorn api.fast:app --reload --port 8000
#======================#
# GCP #
#======================#
gcloud-set-project:
gcloud config set project $(GCP_PROJECT)
#======================#
# Docker #
#======================#
# Local images - using local computer's architecture
# i.e. linux/amd64 for Windows / Linux / Apple with Intel chip
# linux/arm64 for Apple with Apple Silicon (M1 / M2 chip)
docker_build_local:
docker build --tag=$(DOCKER_IMAGE_NAME):local .
docker_run_local:
docker run \
-e PORT=8000 -p $(DOCKER_LOCAL_PORT):8000 \
--env-file .env \
$(DOCKER_IMAGE_NAME):local
docker_run_local_interactively:
docker run -it \
-e PORT=8000 -p $(DOCKER_LOCAL_PORT):8000 \
--env-file .env \
$(DOCKER_IMAGE_NAME):local \
bash
# Cloud images - using architecture compatible with cloud, i.e. linux/amd64
DOCKER_IMAGE_PATH := $(GCP_REGION)-docker.pkg.dev/$(GCP_PROJECT)/$(DOCKER_REPO_NAME)/$(DOCKER_IMAGE_NAME)
docker_show_image_path:
@echo $(DOCKER_IMAGE_PATH)
docker_build:
docker build \
--platform linux/amd64 \
-t $(DOCKER_IMAGE_PATH):prod .
# Alternative if previous doesn´t work. Needs additional setup.
# Probably don´t need this. Used to build arm on linux amd64
docker_build_alternative:
docker buildx build --load \
--platform linux/amd64 \
-t $(DOCKER_IMAGE_PATH):prod .
docker_run:
docker run \
--platform linux/amd64 \
-e PORT=8000 -p $(DOCKER_LOCAL_PORT):8000 \
--env-file .env \
$(DOCKER_IMAGE_PATH):prod
docker_run_interactively:
docker run -it \
--platform linux/amd64 \
-e PORT=8000 -p $(DOCKER_LOCAL_PORT):8000 \
--env-file .env \
$(DOCKER_IMAGE_PATH):prod \
bash
# Push and deploy to cloud
docker_allow:
gcloud auth configure-docker $(GCP_REGION)-docker.pkg.dev
docker_create_repo:
gcloud artifacts repositories create $(DOCKER_REPO_NAME) \
--repository-format=docker \
--location=$(GCP_REGION) \
--description="Repository for storing docker images"
docker_push:
docker push $(DOCKER_IMAGE_PATH):prod
docker_deploy:
gcloud run deploy \
--image $(DOCKER_IMAGE_PATH):prod \
--memory $(GAR_MEMORY) \
--region $(GCP_REGION) \
--env-vars-file .env.yaml