-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
86 lines (75 loc) · 2.35 KB
/
Makefile
File metadata and controls
86 lines (75 loc) · 2.35 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
80
81
82
83
84
85
86
# Copyright (c) 2022-2025 AccelByte Inc. All Rights Reserved.
# This is licensed software from AccelByte Inc, for limitations
# and restrictions contact your company contract manager.
SHELL := /bin/bash
PROJECT_NAME := $(shell basename "$$(pwd)")
GRADLE_IMAGE := gradle:7.6.4-jdk17
GOLANG_IMAGE := golang:1.24-alpine3.21
PROTOC_IMAGE := rvolosatovs/protoc:4.1.0
BUILD_CACHE_VOLUME := $(shell echo '$(PROJECT_NAME)' | sed 's/[^a-zA-Z0-9_-]//g')-build-cache
.PHONY: build
build: build_server build_gateway
proto:
docker run -t --rm \
-u $$(id -u):$$(id -g) \
-v $$(pwd):/data \
-w /data \
--entrypoint /bin/bash \
${PROTOC_IMAGE} \
proto.sh
build_server: prepare_build_cache
docker run -t --rm \
-u $$(id -u):$$(id -g) \
-v $(BUILD_CACHE_VOLUME):/tmp/build-cache \
-v $$(pwd):/data \
-w /data \
$(GRADLE_IMAGE) \
gradle \
--gradle-user-home /tmp/build-cache/gradle \
--project-cache-dir /tmp/build-cache/gradle \
--console=plain \
--info \
--no-daemon \
build
build_gateway: proto prepare_build_cache
docker run -t --rm -u $$(id -u):$$(id -g) \
-e GOCACHE=/tmp/build-cache/go/cache \
-e GOMODCACHE=/tmp/build-cache/go/modcache \
-v $(BUILD_CACHE_VOLUME):/tmp/build-cache \
-v $$(pwd):/data \
-w /data/gateway \
${GOLANG_IMAGE} \
go build -modcacherw -o grpc_gateway
run_server: prepare_build_cache
docker run -t --rm -u $$(id -u):$$(id -g) \
--env-file .env \
-v $(BUILD_CACHE_VOLUME):/tmp/build-cache \
-v $$(pwd):/data/ \
-w /data \
-p 6565:6565 \
-p 8080:8080 \
${GRADLE_IMAGE} \
gradle \
--gradle-user-home /tmp/build-cache/gradle \
--project-cache-dir /tmp/build-cache/gradle \
--console=plain \
--info \
--no-daemon \
run
run_gateway: proto prepare_build_cache
docker run -it --rm -u $$(id -u):$$(id -g) \
-e GOCACHE=/tmp/build-cache/go/cache \
-e GOMODCACHE=/tmp/build-cache/go/modcache \
--env-file .env \
-v $(BUILD_CACHE_VOLUME):/tmp/build-cache \
-v $$(pwd):/data \
-w /data/gateway \
-p 8000:8000 \
--add-host host.docker.internal:host-gateway \
${GOLANG_IMAGE} \
go run main.go --grpc-addr host.docker.internal:6565
prepare_build_cache:
docker run -t --rm \
-v $(BUILD_CACHE_VOLUME):/tmp/build-cache \
busybox:1.37.0 \
chown $$(id -u):$$(id -g) /tmp/build-cache # Fix /tmp/build-cache folder owned by root