-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMakefile
99 lines (83 loc) · 2.79 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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
# Copyright (c) 2024 AccelByte Inc. All Rights Reserved.
# This is licensed software from AccelByte Inc, for limitations
# and restrictions contact your company contract manager.
SHELL := /bin/bash
IMAGE_NAME := $(shell basename "$$(pwd)")-app
BUILDER := extend-builder
PYTHON_VERSION := 3.10
TEST_SAMPLE_CONTAINER_NAME := sample-service-extension-test
SOURCE_DIR := src
TEST_DIR := test
.PHONY: proto test
proto:
docker run -t --rm -u $$(id -u):$$(id -g) \
-v $$(pwd):/build \
-w /build \
--entrypoint /bin/bash \
rvolosatovs/protoc:4.1.0 \
proto.sh
build_server:
build_gateway: proto
docker run -t --rm -u $$(id -u):$$(id -g) \
-e GOCACHE=/data/.cache/go-cache \
-e GOPATH=/data/.cache/go-path \
-v $$(pwd):/data \
-w /data/gateway \
golang:1.20-alpine3.19 \
go build -modcacherw -o grpc_gateway
run_server:
docker run --rm -it -u $$(id -u):$$(id -g) \
-e HOME=/data \
--env-file .env \
-v $$(pwd):/data \
-w /data \
--entrypoint /bin/sh \
-p 6565:6565 \
-p 8080:8080 \
python:${PYTHON_VERSION}-slim \
-c 'python -m pip install -r requirements.txt \
&& PYTHONPATH=${SOURCE_DIR}:${TEST_DIR} python -m app'
run_gateway: proto
docker run -it --rm -u $$(id -u):$$(id -g) \
-e GOCACHE=/data/.cache/go-cache \
-e GOPATH=/data/.cache/go-path \
--env-file .env \
-v $$(pwd):/data \
-w /data/gateway \
-p 8000:8000 \
--add-host host.docker.internal:host-gateway \
golang:1.20-alpine3.19 \
go run main.go --grpc-addr host.docker.internal:6565
help:
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.txt \
&& PYTHONPATH=${SOURCE_DIR}:${TEST_DIR} python -m app --help'
build: build_server build_gateway
imagex:
docker buildx inspect $(BUILDER) || docker buildx create --name $(BUILDER) --use
docker buildx build --tag $(IMAGE_NAME) --platform linux/amd64 .
docker buildx build --tag $(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 --tag $(REPO_URL):$(IMAGE_TAG) --platform linux/amd64 --push .
docker buildx rm --keep-state $(BUILDER)
test_with_env:
@test -n "$(ENV_FILE_PATH)" || (echo "ENV_FILE_PATH is not set" ; exit 1)
docker run --rm -t \
-u $$(id -u):$$(id -g) \
-v $$(pwd):/data \
-w /data -e HOME=/data \
--env-file $(ENV_FILE_PATH) \
--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'