Compare commits
22 Commits
common-sub
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
|
5f0e0b41f7
|
|||
|
e038672457
|
|||
| c1ca80b09b | |||
| ed6638cebf | |||
| 3b62f0648a | |||
| 17be6f427d | |||
| d08e02a46c | |||
|
|
d9485d2fdf | ||
|
|
8096a291e6 | ||
|
|
4a80310c33 | ||
|
|
d77bfb210a | ||
|
|
1f7af65220 | ||
|
|
44975664b6 | ||
|
|
05206686ad | ||
|
|
2de53def19 | ||
|
|
a85a7aa84f | ||
|
|
0d2235b6a3 | ||
|
|
dbe0d47f99 | ||
|
|
c7c547c80f | ||
|
|
a403f6f068 | ||
|
|
32cd04c7ec | ||
|
|
a820e9a297 |
32
.gitea/workflows/minecraft.yaml
Normal file
32
.gitea/workflows/minecraft.yaml
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
name: Minecraft Java Image
|
||||||
|
run-name: Build and Push the Minecraft Java Image
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
paths:
|
||||||
|
- Dockerfile
|
||||||
|
- IMAGE
|
||||||
|
- VERSION
|
||||||
|
- .gitea/workflows/minecraft.yaml
|
||||||
|
schedule:
|
||||||
|
- cron: '@daily'
|
||||||
|
jobs:
|
||||||
|
build-and-push:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
if: gitea.ref == 'refs/heads/master'
|
||||||
|
steps:
|
||||||
|
- name: Check out repository code
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
- name: Login to Gitea Registry
|
||||||
|
uses: docker/login-action@v2
|
||||||
|
with:
|
||||||
|
registry: gitea.reeseapps.com
|
||||||
|
username: ${{ secrets.REGISTRY_USERNAME }}
|
||||||
|
password: ${{ secrets.REGISTRY_PASSWORD }}
|
||||||
|
- name: Build and push Docker image
|
||||||
|
uses: https://github.com/docker/build-push-action@v5
|
||||||
|
with:
|
||||||
|
context: ${{ gitea.workspace }}
|
||||||
|
file: ${{ gitea.workspace }}/Dockerfile
|
||||||
|
push: true
|
||||||
|
tags: "gitea.reeseapps.com/services/minecraft:latest,gitea.reeseapps.com/services/minecraft:${{gitea.sha}}"
|
||||||
|
no-cache: true
|
||||||
1
.gitlab/.gitignore
vendored
Normal file
1
.gitlab/.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
|||||||
|
.gitlab
|
||||||
@@ -1,34 +1,21 @@
|
|||||||
SHELL := /bin/bash
|
SHELL := /bin/bash
|
||||||
|
|
||||||
PROJECT_NAME ?= $(shell git config --local remote.origin.url|sed -n 's#.*/\([^.]*\)\.git#\1#p')
|
PROJECT_NAME ?= $(shell git config --local remote.origin.url | sed -n 's\#.*/\([^.]*\)\.git\#\1\#p')
|
||||||
VERSION ?= $(shell cat VERSION)
|
VERSION ?= $(shell cat VERSION)
|
||||||
IMAGE ?= $(shell cat IMAGE):$(VERSION)
|
IMAGE ?= $(shell cat IMAGE):$(VERSION)
|
||||||
IMAGE_LATEST ?= $(shell cat IMAGE):latest
|
IMAGE_LATEST ?= $(shell cat IMAGE):latest
|
||||||
PWD ?= $(shell pwd)
|
PWD ?= $(shell pwd)
|
||||||
STASH ?= "common-update-stash"
|
STASH ?= "common-update-stash"
|
||||||
|
MAKE_BRANCH ?= main
|
||||||
|
|
||||||
include .gitlab/make/docker.makefile
|
include .gitlab/make/docker.makefile
|
||||||
include .gitlab/make/helm.makefile
|
include .gitlab/make/helm.makefile
|
||||||
include .gitlab/make/kaniko.makefile
|
include .gitlab/make/kaniko.makefile
|
||||||
include .gitlab/make/truenas.makefile
|
include .gitlab/make/truenas.makefile
|
||||||
include .gitlab/make/git.makefile
|
include .gitlab/make/git.makefile
|
||||||
|
include .gitlab/make/kubectl.makefile
|
||||||
|
|
||||||
.PHONY: warning
|
# git subtree add --prefix .gitlab --squash --message "Merge update from Common" -q git@gitlab.ducoterra.net:services/common.git main
|
||||||
warning:
|
|
||||||
@printf "Running a potentially destructive command. If a conflict occurs, fix the conflict and re-run the command.\n"
|
|
||||||
@printf "Cancel with ctrl + c within 3 seconds."
|
|
||||||
@sleep 3
|
|
||||||
|
|
||||||
.PHONY: make-stash-drop
|
|
||||||
make-stash-drop:
|
|
||||||
@if [ ! -z "$$(git stash list | grep -r 'stash@{0}.*common')" ]; then git stash drop; fi
|
|
||||||
|
|
||||||
.PHONY: make-update
|
.PHONY: make-update
|
||||||
make-update:
|
make-update:
|
||||||
@git subtree pull --prefix .gitlab --message "Merge update from Common" -q common main
|
@git subtree pull --prefix .gitlab --squash --message "Merge update from Common" -q git@gitlab.ducoterra.net:services/common.git $(MAKE_BRANCH)
|
||||||
|
|
||||||
.PHONY: make-push
|
|
||||||
make-push: warning
|
|
||||||
@make make-update
|
|
||||||
@git subtree split --branch common/$(PROJECT_NAME) --prefix .gitlab
|
|
||||||
@git push common common/$(PROJECT_NAME):common/$(PROJECT_NAME)
|
|
||||||
|
|||||||
@@ -2,8 +2,7 @@
|
|||||||
|
|
||||||
```bash
|
```bash
|
||||||
# Add the subtree as a remote
|
# Add the subtree as a remote
|
||||||
git remote add common git@gitlab.ducoterra.net:services/common.git
|
git subtree add --prefix .gitlab git@gitlab.ducoterra.net:services/common.git main --squash --message "Add Common .gitlab Subtree"
|
||||||
git subtree add --prefix .gitlab common main
|
|
||||||
|
|
||||||
# Now you can run the following to update
|
# Now you can run the following to update
|
||||||
make make-update
|
make make-update
|
||||||
|
|||||||
@@ -3,27 +3,21 @@ docker-init:
|
|||||||
@touch VERSION
|
@touch VERSION
|
||||||
@touch IMAGE
|
@touch IMAGE
|
||||||
|
|
||||||
.PHONY: buildx-context
|
.PHONY: docker-buildx-context
|
||||||
buildx-context:
|
docker-buildx-context:
|
||||||
docker buildx create --name container-builder --use --platform linux/amd64,linux/arm64
|
@docker buildx create --name container-builder --use --platform linux/amd64,linux/arm64
|
||||||
|
|
||||||
.PHONY: buildx-clear
|
.PHONY: docker-buildx-clear
|
||||||
buildx-clear:
|
docker-buildx-clear:
|
||||||
docker buildx rm container-builder
|
@docker buildx rm container-builder
|
||||||
|
|
||||||
.PHONY: build
|
.PHONY: docker-build
|
||||||
build:
|
docker-build:
|
||||||
docker buildx build --load . -t $(IMAGE)
|
docker build . -t $(IMAGE)
|
||||||
@docker buildx build --load . -t $(IMAGE_LATEST)
|
|
||||||
|
|
||||||
.PHONY: push
|
.PHONY: docker-push
|
||||||
push:
|
docker-push:
|
||||||
-make buildx-clear
|
-make docker-buildx-clear
|
||||||
@make buildx-context
|
@make docker-buildx-context
|
||||||
docker buildx build --platform linux/amd64,linux/arm64 --push . -t $(IMAGE)
|
docker buildx build --platform linux/amd64,linux/arm64 --push . -t $(IMAGE)
|
||||||
@docker buildx build --platform linux/amd64,linux/arm64 --push . -t $(IMAGE_LATEST)
|
@docker buildx build --platform linux/amd64,linux/arm64 --push . -t $(IMAGE_LATEST)
|
||||||
|
|
||||||
.PHONY: docker-release
|
|
||||||
docker-release:
|
|
||||||
@yq e ".services.minecraft.image = \"$(IMAGE)\"" -i docker-compose.yaml
|
|
||||||
@make push
|
|
||||||
|
|||||||
@@ -2,3 +2,15 @@
|
|||||||
helm-release:
|
helm-release:
|
||||||
@yq e ".version = \"$(shell cat VERSION)\"" -i helm/Chart.yaml
|
@yq e ".version = \"$(shell cat VERSION)\"" -i helm/Chart.yaml
|
||||||
@yq e ".appVersion = \"$(shell cat VERSION)\"" -i helm/Chart.yaml
|
@yq e ".appVersion = \"$(shell cat VERSION)\"" -i helm/Chart.yaml
|
||||||
|
|
||||||
|
.PHONY: install
|
||||||
|
install: set-namespace
|
||||||
|
helm install $(PROJECT_NAME) ./helm --set image=$(IMAGE)
|
||||||
|
|
||||||
|
.PHONY: upgrade
|
||||||
|
upgrade: set-namespace
|
||||||
|
helm upgrade $(PROJECT_NAME) ./helm --set image=$(IMAGE)
|
||||||
|
|
||||||
|
.PHONY: uninstall
|
||||||
|
uninstall: set-namespace
|
||||||
|
helm uninstall $(PROJECT_NAME)
|
||||||
|
|||||||
11
.gitlab/make/kubectl.makefile
Normal file
11
.gitlab/make/kubectl.makefile
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
.PHONY: set-namespace
|
||||||
|
set-namespace:
|
||||||
|
kubectl config set contexts.$(shell kubectl config current-context).namespace $(shell cat NAMESPACE)
|
||||||
|
|
||||||
|
.PHONY: create-regcred
|
||||||
|
create-regcred:
|
||||||
|
@kubectl create secret docker-registry regcred \
|
||||||
|
--docker-server=registry.ducoterra.net \
|
||||||
|
--docker-username=$(shell vault kv get -field username secret/duconet/basic-auth) \
|
||||||
|
--docker-password='$(shell vault kv get -field password secret/duconet/basic-auth)' \
|
||||||
|
--docker-email=$(shell vault kv get -field username secret/duconet/basic-auth)
|
||||||
@@ -1,3 +1,5 @@
|
|||||||
.PHONY: chart-release
|
.PHONY: chart-release
|
||||||
chart-release:
|
chart-release:
|
||||||
@rsync -av $(CHART)/helm/ charts/$(CHART)/$(shell cat $(CHART)/VERSION)/
|
@rsync -av $(CHART)/helm/ charts/$(CHART)/$(shell cat $(CHART)/VERSION)/
|
||||||
|
@git add charts/$(CHART)
|
||||||
|
@git commit -m "Automated release for chart $(CHART) version $(shell cat $(CHART)/VERSION)" -e
|
||||||
|
|||||||
11
Dockerfile
11
Dockerfile
@@ -1,10 +1,7 @@
|
|||||||
FROM openjdk:latest
|
# Read more about Corretto here:
|
||||||
|
# https://hub.docker.com/_/amazoncorretto
|
||||||
|
FROM docker.io/amazoncorretto:21
|
||||||
|
|
||||||
RUN groupadd -r minecraft -g 2000
|
|
||||||
RUN useradd --no-log-init minecraft -u 2000 -g 2000 -m
|
|
||||||
WORKDIR /mc_data
|
WORKDIR /mc_data
|
||||||
RUN chown -R minecraft:minecraft .
|
|
||||||
|
|
||||||
USER minecraft
|
CMD ["sh", "-c" , "java -Xmx${MAX_RAM}G -Xms${MIN_RAM}G -jar ./server.jar nogui"]
|
||||||
# Copy files only if they don't yet exist (server.jar, server.properties, etc) and start the server
|
|
||||||
CMD java -Xmx"$MAX_RAM"G -Xms"$MIN_RAM"G -jar ./server.jar nogui
|
|
||||||
|
|||||||
19
Makefile
19
Makefile
@@ -2,12 +2,27 @@ SHELL := /bin/bash
|
|||||||
|
|
||||||
include .gitlab/Makefile
|
include .gitlab/Makefile
|
||||||
|
|
||||||
|
.PHONY: build
|
||||||
|
build:
|
||||||
|
@podman build -f Dockerfile -t localhost/minecraft:latest
|
||||||
|
|
||||||
.PHONY: get-server
|
.PHONY: get-server
|
||||||
get-server:
|
get-server:
|
||||||
@mkdir -p world
|
@mkdir -p world
|
||||||
@echo 'eula=true' > world/eula.txt
|
@echo 'eula=true' > world/eula.txt
|
||||||
@docker run -it -e SERVER_VERSION=1.17.1 -v $(PWD)/world:/downloads ducoterra/get-minecraft:latest
|
@podman run \
|
||||||
|
-it \
|
||||||
|
--rm \
|
||||||
|
-e SERVER_VERSION=1.21.10 \
|
||||||
|
-v $(PWD)/world:/downloads \
|
||||||
|
--security-opt label=disable \
|
||||||
|
--userns keep-id \
|
||||||
|
docker.io/ducoterra/get-minecraft:latest
|
||||||
|
|
||||||
.PHONY: run
|
.PHONY: run
|
||||||
run:
|
run:
|
||||||
docker-compose run --service-ports minecraft
|
docker compose -f compose.yaml up minecraft
|
||||||
|
|
||||||
|
.PHONY: stop
|
||||||
|
stop:
|
||||||
|
docker compose -f compose.yaml down
|
||||||
12
README.md
12
README.md
@@ -3,11 +3,17 @@
|
|||||||
## Running Locally
|
## Running Locally
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
|
# Build
|
||||||
|
make build
|
||||||
|
|
||||||
# download the most recent version of minecraft
|
# download the most recent version of minecraft
|
||||||
make get-server
|
make get-server
|
||||||
|
|
||||||
# Run the server
|
# Run the server
|
||||||
docker-compose up
|
make run
|
||||||
|
|
||||||
|
# Stop the server
|
||||||
|
make stop
|
||||||
```
|
```
|
||||||
|
|
||||||
## Uploading to Docker Hub
|
## Uploading to Docker Hub
|
||||||
@@ -30,13 +36,13 @@ helm upgrade --install minecraft
|
|||||||
|
|
||||||
Your minecraft server will be available on port 25565 by default.
|
Your minecraft server will be available on port 25565 by default.
|
||||||
|
|
||||||
## Create a Backup
|
### Create a Backup in Kubernetes
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
kubectl cp <pod_name>:/mc_data <backup>
|
kubectl cp <pod_name>:/mc_data <backup>
|
||||||
```
|
```
|
||||||
|
|
||||||
## Restore from Backup
|
### Restore from Backup in Kubernetes
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
kubectl cp <backup> <pod_name>:/mc_data
|
kubectl cp <backup> <pod_name>:/mc_data
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
version: '3'
|
|
||||||
services:
|
services:
|
||||||
minecraft:
|
minecraft:
|
||||||
image: ducoterra/minecraft:1.0.2
|
image: localhost/minecraft:latest
|
||||||
stdin_open: true
|
stdin_open: true
|
||||||
tty: true
|
tty: true
|
||||||
volumes:
|
volumes:
|
||||||
@@ -11,3 +10,6 @@ services:
|
|||||||
environment:
|
environment:
|
||||||
- MAX_RAM=1
|
- MAX_RAM=1
|
||||||
- MIN_RAM=1
|
- MIN_RAM=1
|
||||||
|
security_opt:
|
||||||
|
- "label=disable"
|
||||||
|
userns_mode: keep-id
|
||||||
@@ -19,7 +19,7 @@ spec:
|
|||||||
imagePullPolicy: Always
|
imagePullPolicy: Always
|
||||||
env:
|
env:
|
||||||
- name: SERVER_VERSION
|
- name: SERVER_VERSION
|
||||||
value: {{ .Values.server_version }}
|
value: {{ .Values.server_version | quote }}
|
||||||
volumeMounts:
|
volumeMounts:
|
||||||
- mountPath: /downloads
|
- mountPath: /downloads
|
||||||
name: data
|
name: data
|
||||||
|
|||||||
@@ -1 +0,0 @@
|
|||||||
kubectl config set current-context k3os-alpha.dnet-ducoterra-minecraft
|
|
||||||
@@ -1,7 +1,10 @@
|
|||||||
image: hub.ducoterra.net/ducoterra/minecraft:1.16.4
|
image: ducoterra/minecraft:latest
|
||||||
|
get_server:
|
||||||
|
image: ducoterra/get-minecraft:2.0.0
|
||||||
|
server_version: "1.16.4"
|
||||||
port: 20101
|
port: 20101
|
||||||
max_cpu: 8
|
max_cpu: 4
|
||||||
max_ram: 8
|
max_ram: 4
|
||||||
server_props: |
|
server_props: |
|
||||||
max-tick-time=60000
|
max-tick-time=60000
|
||||||
generator-settings=
|
generator-settings=
|
||||||
|
|||||||
@@ -1,7 +1,10 @@
|
|||||||
image: hub.ducoterra.net/ducoterra/minecraft:1.16.4
|
image: ducoterra/minecraft:latest
|
||||||
port: 25566
|
get_server:
|
||||||
|
image: ducoterra/get-minecraft:2.0.0
|
||||||
|
server_version: "1.18"
|
||||||
|
port: 20103
|
||||||
max_cpu: 8
|
max_cpu: 8
|
||||||
max_ram: 6
|
max_ram: 8
|
||||||
server_props: |
|
server_props: |
|
||||||
max-tick-time=60000
|
max-tick-time=60000
|
||||||
generator-settings=
|
generator-settings=
|
||||||
@@ -16,7 +19,7 @@ server_props: |
|
|||||||
op-permission-level=4
|
op-permission-level=4
|
||||||
pvp=true
|
pvp=true
|
||||||
snooper-enabled=true
|
snooper-enabled=true
|
||||||
level-type=amplified
|
level-type=default
|
||||||
hardcore=false
|
hardcore=false
|
||||||
enable-command-block=false
|
enable-command-block=false
|
||||||
max-players=20
|
max-players=20
|
||||||
@@ -28,15 +31,15 @@ server_props: |
|
|||||||
spawn-npcs=true
|
spawn-npcs=true
|
||||||
allow-flight=true
|
allow-flight=true
|
||||||
level-name=world
|
level-name=world
|
||||||
view-distance=64
|
view-distance=32
|
||||||
resource-pack=
|
resource-pack=
|
||||||
spawn-animals=true
|
spawn-animals=true
|
||||||
white-list=true
|
white-list=true
|
||||||
generate-structures=true
|
generate-structures=true
|
||||||
online-mode=true
|
online-mode=true
|
||||||
max-build-height=512
|
max-build-height=256
|
||||||
level-seed=
|
level-seed=
|
||||||
prevent-proxy-connections=false
|
prevent-proxy-connections=false
|
||||||
use-native-transport=true
|
use-native-transport=true
|
||||||
motd=This is gonna be interesting
|
motd=Welcome to testcraft!
|
||||||
enable-rcon=false
|
enable-rcon=false
|
||||||
|
|||||||
Reference in New Issue
Block a user