-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
38 lines (31 loc) · 1.14 KB
/
Copy pathMakefile
File metadata and controls
38 lines (31 loc) · 1.14 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
.PHONY: all build remove create install publish
IMAGE_NAME = refractix/mc-server
IMAGE_TAG = latest
all: build remove create
build:
@echo "building docker image"
docker build -t ${IMAGE_NAME}:${IMAGE_TAG} . --build-arg MC_VERSION=${IMAGE_TAG}
@echo "building done of ${IMAGE_NAME}:${IMAGE_TAG}"
remove:
@echo "removing old container"
-docker rm minecraft-server-${IMAGE_TAG}
@echo "removed minecraft-server-${IMAGE_TAG}"
create:
@echo "creating container"
docker create \
--name=minecraft-server-${IMAGE_TAG} \
--mount 'type=bind,src=/mnt/data/docker/minecraft/data/,dst=/opt/minecraft/etc/' \
-p 25565:25565 \
${IMAGE_NAME}:${IMAGE_TAG}
@echo "created minecraft-server-${IMAGE_TAG}"
install:
@echo "installing systemd unit"
-sudo systemctl stop docker-minecraft.service
sed "s/##IMAGE_TAG##/${IMAGE_TAG}/g" docker-minecraft.service | sudo tee /etc/systemd/system/docker-minecraft.service
@echo "created sytemd unit"
sudo systemctl daemon-reload
sudo systemctl enable docker-minecraft.service
@echo "done installing"
publish:
@echo "publishing image to https://hub.docker.com/r/${IMAGE_NAME}"
docker push ${IMAGE_NAME}:${IMAGE_TAG}