-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
79 lines (64 loc) · 2.26 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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
SHELL := /bin/bash
IMAGE_NAME := $(shell basename "$$(pwd)")-app
BUILDER := extend-builder
PYTHON_VERSION := 3.10
SOURCE_DIR := src
TEST_DIR := test
TEST_SAMPLE_CONTAINER_NAME := sample-override-test
.PHONY: test
clean:
cd ${SOURCE_DIR}/app/proto \
&& rm -fv *_grpc.py *_pb2.py *_pb2.pyi *_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=app/proto=${SOURCE_DIR}/app/proto \
--python_out=${SOURCE_DIR} \
--grpc-python_out=${SOURCE_DIR} \
${SOURCE_DIR}/app/proto/*.proto
build: proto
run:
docker run --rm -it -u $$(id -u):$$(id -g) \
-e HOME=/data \
--env-file .env \
-v $$(pwd):/data \
-w /data \
--entrypoint /bin/sh \
python:${PYTHON_VERSION}-slim \
-c 'python -m pip install -r requirements.txt \
&& PYTHONPATH=${SOURCE_DIR}:${TEST_DIR} python -m app'
help:
docker run --rm -it -u $$(id -u):$$(id -g) \
-e HOME=/data \
--env-file .env \
-v $$(pwd):/data \
-w /data \
--entrypoint /bin/sh \
python:${PYTHON_VERSION}-slim \
-c 'python -m pip install -r requirements.txt \
&& PYTHONPATH=${SOURCE_DIR}:${TEST_DIR} python -m app --help'
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)
test:
docker run --rm -t \
-u $$(id -u):$$(id -g) \
-v $$(pwd):/data \
-w /data -e HOME=/data \
--entrypoint /bin/sh \
python:${PYTHON_VERSION}-slim \
-c 'python -m pip install -r requirements-dev.txt \
&& PYTHONPATH=${SOURCE_DIR}:${TEST_DIR} python -m app_tests'
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