-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
52 lines (45 loc) · 1.39 KB
/
Makefile
File metadata and controls
52 lines (45 loc) · 1.39 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
# 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
PROTOC_IMAGE := proto-builder
IS_INSIDE_DEVCONTAINER := $(REMOTE_CONTAINERS)
BUILD_CACHE_VOLUME := $(shell echo '$(PROJECT_NAME)' | sed 's/[^a-zA-Z0-9_-]//g')-build-cache
build: prepare_build_cache
ifneq ($(IS_INSIDE_DEVCONTAINER),true)
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/ \
$(GOLANG_IMAGE) \
go build -modcacherw
else
go build -modcacherw
endif
proto_image:
ifneq ($(IS_INSIDE_DEVCONTAINER),true)
docker build --target proto-builder -t $(PROTOC_IMAGE) .
endif
proto: proto_image
ifneq ($(IS_INSIDE_DEVCONTAINER),true)
docker run --tty --rm --user $$(id -u):$$(id -g) \
--volume $$(pwd):/build \
--workdir /build \
--entrypoint /bin/bash \
$(PROTOC_IMAGE) \
proto.sh
else
./proto.sh
endif
prepare_build_cache:
ifneq ($(IS_INSIDE_DEVCONTAINER),true)
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
endif