-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
51 lines (39 loc) · 1.25 KB
/
Makefile
File metadata and controls
51 lines (39 loc) · 1.25 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
# Registry where you want store your Docker images
DOCKER_REGISTRY = gcr.io/${GCLOUD-PROJECT-ID}
PORTS = 8080:8080
PROJECT_NAME = proxy-service
GCLOUD-PROJECT-ID = home-260209
ENV = dev
MEMORY_LIMIT = 50M
ENV_VARIABLES = $(shell ./utils/convert_env.py $(shell pwd)/.env)
REPO_PATH := $(shell git rev-parse --show-toplevel)
CHANGED_FILES := $(shell git diff-files)
ifeq ($(strip $(CHANGED_FILES)),)
GIT_VERSION := $(shell git describe --tags --long --always)
else
GIT_VERSION := $(shell git describe --tags --long --always)-dirty-$(shell git diff | shasum -a256 | cut -c -6)
endif
IMG ?= ${DOCKER_REGISTRY}/${PROJECT_NAME}
TAG ?= $(GIT_VERSION)
activate:
pip install --user poetry
poetry install
poetry shell
test:
PYTHONPATH=$(shell pwd)/project poetry run pytest -vv ${TEST_CASE}
lock:
poetry lock
linter:
PYTHONPATH=$(shell pwd)/project poetry run black .
# pre production
build:
docker build -t ${IMG}:${TAG} .
run: build
docker run -it -p ${PORTS} --rm --env-file .env ${IMG}:${TAG}
push: linter test lock build
docker push ${IMG}:${TAG}
# deploy
gcloud-deploy: push
gcloud run deploy ${PROJECT_NAME} --image ${IMG}:${TAG} --memory ${MEMORY_LIMIT} --platform managed --set-env-vars ${ENV_VARIABLES}
gcloud-remove:
gcloud run service delete ${PROJECT_NAME}