-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
59 lines (48 loc) · 2.05 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
52
53
54
55
56
57
58
59
PIP_EXEC_PATH = bin/pip
PROTO_DIR = app/proto
SOURCE_DIR = src
TESTS_DIR = tests
VENV_DIR = venv
IMAGE_NAME := $(shell basename "$$(pwd)")-app
BUILDER := extend-builder
clean:
rm -f ${SOURCE_DIR}/${PROTO_DIR}/*_grpc.py
rm -f ${SOURCE_DIR}/${PROTO_DIR}/*_pb2.py
rm -f ${SOURCE_DIR}/${PROTO_DIR}/*_pb2.pyi
rm -f ${SOURCE_DIR}/${PROTO_DIR}/*_pb2_grpc.py
proto: clean
docker run -t --rm -u $$(id -u):$$(id -g) -v $$(pwd):/data/ -w /data/ rvolosatovs/protoc:4.0.0 \
--proto_path=${PROTO_DIR}=${SOURCE_DIR}/${PROTO_DIR} \
--python_out=${SOURCE_DIR} \
--grpc-python_out=${SOURCE_DIR} \
${SOURCE_DIR}/${PROTO_DIR}/*.proto
build: proto
image:
docker buildx build -t ${IMAGE_NAME} --load .
imagex:
docker buildx inspect $(BUILDER) || docker buildx create --name $(BUILDER) --use
docker buildx build -t ${IMAGE_NAME} --platform linux/amd64 .
docker buildx build -t ${IMAGE_NAME} --load .
docker buildx rm --keep-state $(BUILDER)
imagex_push:
@test -n "$(IMAGE_TAG)" || (echo "IMAGE_TAG is not set (e.g. 'v0.1.0', 'latest')"; exit 1)
@test -n "$(REPO_URL)" || (echo "REPO_URL is not set"; exit 1)
docker buildx inspect $(BUILDER) || docker buildx create --name $(BUILDER) --use
docker buildx build -t ${REPO_URL}:${IMAGE_TAG} --platform linux/amd64 --push .
docker buildx rm --keep-state $(BUILDER)
beautify:
docker run -t --rm -u $$(id -u):$$(id -g) -v $$(pwd):/data/ -w /data/ cytopia/black:22-py3.9 \
${SOURCE_DIR} \
${TESTS_DIR}
test:
docker run --rm -t -u $$(id -u):$$(id -g) -v $$(pwd):/data -w /data -e HOME=/tmp --entrypoint /bin/sh python:3.9-slim \
-c 'pip install -r requirements.txt && \
PYTHONPATH=${TESTS_DIR}:${SOURCE_DIR} python -m app_tests'
run:
docker run --rm -t -u $$(id -u):$$(id -g) --net=host -v $$(pwd):/data -w /data -e HOME=/tmp --entrypoint /bin/sh python:3.9-slim \
-c 'pip install -r requirements.txt && \
PYTHONPATH=${SOURCE_DIR} python -m app'
ngrok:
@which ngrok || (echo "ngrok is not installed" ; exit 1)
@test -n "$(NGROK_AUTHTOKEN)" || (echo "NGROK_AUTHTOKEN is not set" ; exit 1)
ngrok tcp 6565 # gRPC server port