-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
56 lines (47 loc) · 1.71 KB
/
Makefile
File metadata and controls
56 lines (47 loc) · 1.71 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
# Copyright (c) 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)")
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 proto
build: build_server build_gateway
proto:
docker run --tty --rm --user $$(id -u):$$(id -g) \
--volume $$(pwd):/build \
--workdir /build \
--entrypoint /bin/bash \
rvolosatovs/protoc:4.1.0 \
proto.sh
build_server: proto
build_gateway: proto
docker run -t --rm \
-v $(BUILD_CACHE_VOLUME):/tmp/build-cache \
$(GOLANG_IMAGE) \
chown $$(id -u):$$(id -g) /tmp/build-cache # Fix /tmp/build-cache folder owned by root
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_gateway: proto
docker run -t --rm \
-v $(BUILD_CACHE_VOLUME):/tmp/build-cache \
$(GOLANG_IMAGE) \
chown $$(id -u):$$(id -g) /tmp/build-cache # Fix /tmp/build-cache folder owned by root
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