-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
65 lines (48 loc) · 1.44 KB
/
Makefile
File metadata and controls
65 lines (48 loc) · 1.44 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
.ONESHELL:
SHELL := /bin/bash
# Commands where rest of the args is treated as one argument.
CMDS_ALL_ARGS_IS_ONE_LIST = find setup-env server new-server image
FIRST_ARG = $(firstword $(MAKECMDGOALS))
ifeq ($(FIRST_ARG),$(filter $(FIRST_ARG),$(CMDS_ALL_ARGS_IS_ONE_LIST)))
# use the rest as arguments to supply the cmds.
RUN_ARGS := $(wordlist 2,$(words $(MAKECMDGOALS)),$(MAKECMDGOALS))
# ...and turn them into do-nothing targets
$(eval $(RUN_ARGS):;@:)
endif
IMAGE_NAME = minecraft.vanilla.server
IMAGES := $(shell docker images --filter "reference=$(IMAGE_NAME):*" -q | tr '\n' ' ')
OUT_DIR = out
.SILENT: setup-env out-clean find
find:
./scripts/find_versions.sh "$(RUN_ARGS)"
agree-eula:
@mkdir -p $(OUT_DIR)
echo "eula=TRUE" > $(OUT_DIR)/eula.txt
setup-env:
./scripts/setup_mc_env.sh -img $(IMAGE_NAME) -mcv "$(RUN_ARGS)"
up:
@mkdir -p $(OUT_DIR)
docker compose up -d && docker compose attach mc-server
down:
docker compose down
build:
docker compose build
rebuild:
docker compose build --no-cache
# Clear out the OUT_DIR folder. Only keep the eula.txt if exists.
out-clean:
mkdir -p $(OUT_DIR)
if [[ -f "$(OUT_DIR)/eula.txt" ]]; then
mv $(OUT_DIR)/eula.txt eula.out
fi
rm -rf $(OUT_DIR)/{*,.*}
if [[ -f eula.out ]]; then
mv eula.out $(OUT_DIR)/eula.txt
fi
image-clean:
docker rmi $(IMAGES)
server: setup-env up
image: setup-env build
new-server: out-clean setup-env rebuild up
clean: down out-clean
reset: clean image-clean