-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
79 lines (64 loc) · 2.58 KB
/
Copy pathMakefile
File metadata and controls
79 lines (64 loc) · 2.58 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
MAKEFLAGS=--no-builtin-rules --no-builtin-variables --always-make
ROOT := $(realpath $(dir $(lastword $(MAKEFILE_LIST))))
SHELL := /bin/bash
PROJECT_ID := my-python-448116
vendor:
source venv/bin/activate && poetry install
update-modules:
source venv/bin/activate && poetry update
types:
source venv/bin/activate && mypy .
test:
source venv/bin/activate && pytest
run-api:
source venv/bin/activate && PROJECT_ID=$(PROJECT_ID) IS_LOCAL=true python -m entrypoint.api
run-graphql:
source venv/bin/activate && PROJECT_ID=$(PROJECT_ID) IS_LOCAL=true python -m entrypoint.graphql
run-clean-assistant:
source venv/bin/activate && PROJECT_ID=$(PROJECT_ID) IS_LOCAL=true python -m entrypoint.clean_assistant
gcloud-login:
gcloud --quiet config set project $(PROJECT_ID)
gcloud auth application-default login
push-pdf-assistant:
gcloud --quiet config set project $(PROJECT_ID)
docker build --platform linux/amd64 -t asia-northeast1-docker.pkg.dev/$(PROJECT_ID)/app/pdf-assistant:latest .
gcloud auth configure-docker asia-northeast1-docker.pkg.dev
docker push asia-northeast1-docker.pkg.dev/$(PROJECT_ID)/app/pdf-assistant:latest
deploy: push-pdf-assistant
gcloud run deploy pdf-assistant-api \
--image asia-northeast1-docker.pkg.dev/$(PROJECT_ID)/app/pdf-assistant:latest \
--add-cloudsql-instances $(PROJECT_ID):asia-northeast1:pdf-assistant \
--region asia-northeast1 \
--cpu 1000m \
--memory 1Gi \
--port 8080 \
--platform managed \
--no-allow-unauthenticated \
--service-account cloud-run-sa@$(PROJECT_ID).iam.gserviceaccount.com \
--set-env-vars PROJECT_ID=$(PROJECT_ID) \
--ingress all \
--command "sh" \
--args "-c,python -m entrypoint.api"
gcloud run jobs deploy clean-assistant \
--image asia-northeast1-docker.pkg.dev/$(PROJECT_ID)/app/pdf-assistant:latest \
--set-cloudsql-instances $(PROJECT_ID):asia-northeast1:pdf-assistant \
--region asia-northeast1 \
--cpu 1000m \
--memory 512Mi \
--service-account cloud-run-sa@$(PROJECT_ID).iam.gserviceaccount.com \
--set-env-vars PROJECT_ID=$(PROJECT_ID) \
--max-retries 0 \
--parallelism 1 \
--tasks 1 \
--command "sh" \
--args "-c,python -m entrypoint.clean_assistant"
terraform-plan:
gcloud config set project $(PROJECT_ID)
cd terraform && terraform plan
terraform-apply:
gcloud config set project $(PROJECT_ID)
cd terraform && terraform apply
clean-docker:
docker system prune -a -f
connect-cloud-sql:
./cloud_sql/proxy $(PROJECT_ID):asia-northeast1:pdf-assistant