From ecc25394717f9c7d9c2b748509123aba29dbe607 Mon Sep 17 00:00:00 2001 From: ducoterra Date: Tue, 2 Nov 2021 16:01:08 -0400 Subject: [PATCH] Squashed 'minecraft/' changes from 0d2235b..0520668 0520668 Merge update from Common 4497566 Squashed '.gitlab/' changes from 731ada6..cf41f2e 2de53de Remove .common a85a7aa Merge branch 'common-subtree' a074005 Add '.gitlab/' from commit '731ada6a3d65b2347ccf204cfe09ee278a4f0594' 422f4d4 remove .gitlab subtree 731ada6 Merge branch 'make-update-fixes' into 'main' c3e6d73 Switch to "subtree split" push strategy 3c91292 Make user stash their own damn changes d86b505 Add PROJECT_NAME and VERSION 9d0c9c6 Update README with "common" remote 30fb8c2 Merge branch 'docker-buidlx-overhaul' into 'main' fd96b3f Merge branch 'git-release' into 'main' a6053ed Add make git-release 3563c5c Add make docker-release 40a217b Use buildx to create multi-arch images 5e2bc5f Switch to container-builder buildx platform a5aa0ca Automated release for version 1.0.2 65b3a84 make subtree "split" overhaul d181d45 Overhaul for get-server v. 2.0.0 9eed509 Don't squash on pull b07a2c0 Run update after make-push 22a952d Remove warning from make-update 0f6eeb7 Add make-stash-drop command f81d846 Only pop stash if changes afed93f Add warning to make-update and make-push 6239af7 Ignore git stash pop failures 2f76759 Add make-push command 66b4fdb Ignore subtree pull failures da69418 Switch to url-based subtree with `make-update` ba12c92 Remove docker-run 74a4a4e Transition to .gitlab prefix 3e8ca71 Add chart-release to truenas.makefile 4146777 Add helm.makefile 8a52a21 Switch to multi-makefile strategy f187522 init git-subtree-dir: minecraft git-subtree-split: 05206686ad84ad388c98578becfc5cfe3a13fdb4 --- .common/Makefile | 27 ----------------- .gitignore | 3 +- .gitlab/Makefile | 18 ++++++++++++ .gitlab/README.md | 9 ++++++ .gitlab/make/docker.makefile | 29 ++++++++++++++++++ .gitlab/make/git.makefile | 5 ++++ .gitlab/make/helm.makefile | 4 +++ .gitlab/make/kaniko.makefile | 0 .gitlab/make/truenas.makefile | 5 ++++ Makefile | 14 ++++++++- README.md | 55 +++++++++-------------------------- VERSION | 2 +- docker-compose.yaml | 13 +++++++++ helm/Chart.yaml | 7 ++--- helm/templates/deploy.yaml | 7 ----- helm/values.yaml | 2 +- 16 files changed, 116 insertions(+), 84 deletions(-) delete mode 100644 .common/Makefile create mode 100644 .gitlab/Makefile create mode 100644 .gitlab/README.md create mode 100644 .gitlab/make/docker.makefile create mode 100644 .gitlab/make/git.makefile create mode 100644 .gitlab/make/helm.makefile create mode 100644 .gitlab/make/kaniko.makefile create mode 100644 .gitlab/make/truenas.makefile create mode 100644 docker-compose.yaml diff --git a/.common/Makefile b/.common/Makefile deleted file mode 100644 index 0792771..0000000 --- a/.common/Makefile +++ /dev/null @@ -1,27 +0,0 @@ -SHELL := /bin/bash - -IMAGE ?= $(shell cat IMAGE):$(shell cat VERSION) -IMAGE_LATEST ?= $(shell cat IMAGE):latest -PWD ?= $(shell pwd) - -.PHONY: buildx-context -buildx-context: - docker buildx create --name arm64 --use --platform linux/amd64,linux/arm64 - -.PHONY: buildx-clear -buildx-clear: - docker buildx rm arm64 - -.PHONY: build -build: - docker buildx build --load . -t $(IMAGE) - @docker buildx build --load . -t $(IMAGE_LATEST) - -.PHONY: push -push: - docker buildx build --platform linux/amd64 --push . -t $(IMAGE) - @docker buildx build --platform linux/amd64 --push . -t $(IMAGE_LATEST) - -.PHONY: run -run: - docker run -it -v $(PWD):/mc_data $(IMAGE) bash diff --git a/.gitignore b/.gitignore index adbb97d..fe29ac4 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ -data/ \ No newline at end of file +data/ +world/ diff --git a/.gitlab/Makefile b/.gitlab/Makefile new file mode 100644 index 0000000..c71a072 --- /dev/null +++ b/.gitlab/Makefile @@ -0,0 +1,18 @@ +SHELL := /bin/bash + +PROJECT_NAME ?= $(shell git config --local remote.origin.url | sed -n 's\#.*/\([^.]*\)\.git\#\1\#p') +VERSION ?= $(shell cat VERSION) +IMAGE ?= $(shell cat IMAGE):$(VERSION) +IMAGE_LATEST ?= $(shell cat IMAGE):latest +PWD ?= $(shell pwd) +STASH ?= "common-update-stash" + +include .gitlab/make/docker.makefile +include .gitlab/make/helm.makefile +include .gitlab/make/kaniko.makefile +include .gitlab/make/truenas.makefile +include .gitlab/make/git.makefile + +.PHONY: make-update +make-update: + @git subtree pull --prefix .gitlab --squash --message "Merge update from Common" -q git@gitlab.ducoterra.net:services/common.git main diff --git a/.gitlab/README.md b/.gitlab/README.md new file mode 100644 index 0000000..5680c6b --- /dev/null +++ b/.gitlab/README.md @@ -0,0 +1,9 @@ +# Adding the "common" subtree as your .gitlab folder + +```bash +# Add the subtree as a remote +git subtree add --prefix .gitlab git@gitlab.ducoterra.net:services/common.git main --squash --message "Add Common .gitlab Subtree" + +# Now you can run the following to update +make make-update +``` diff --git a/.gitlab/make/docker.makefile b/.gitlab/make/docker.makefile new file mode 100644 index 0000000..23e4a52 --- /dev/null +++ b/.gitlab/make/docker.makefile @@ -0,0 +1,29 @@ +.PHONY: docker-init +docker-init: + @touch VERSION + @touch IMAGE + +.PHONY: buildx-context +buildx-context: + docker buildx create --name container-builder --use --platform linux/amd64,linux/arm64 + +.PHONY: buildx-clear +buildx-clear: + docker buildx rm container-builder + +.PHONY: build +build: + docker buildx build --load . -t $(IMAGE) + @docker buildx build --load . -t $(IMAGE_LATEST) + +.PHONY: push +push: + -make buildx-clear + @make buildx-context + docker buildx build --platform linux/amd64,linux/arm64 --push . -t $(IMAGE) + @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 diff --git a/.gitlab/make/git.makefile b/.gitlab/make/git.makefile new file mode 100644 index 0000000..f80a243 --- /dev/null +++ b/.gitlab/make/git.makefile @@ -0,0 +1,5 @@ +.PHONY: git-release +git-release: + @git add . + @git commit -m "Automated release for version $(VERSION)" + @git tag $(VERSION) diff --git a/.gitlab/make/helm.makefile b/.gitlab/make/helm.makefile new file mode 100644 index 0000000..f603af4 --- /dev/null +++ b/.gitlab/make/helm.makefile @@ -0,0 +1,4 @@ +.PHONY: helm-release +helm-release: + @yq e ".version = \"$(shell cat VERSION)\"" -i helm/Chart.yaml + @yq e ".appVersion = \"$(shell cat VERSION)\"" -i helm/Chart.yaml diff --git a/.gitlab/make/kaniko.makefile b/.gitlab/make/kaniko.makefile new file mode 100644 index 0000000..e69de29 diff --git a/.gitlab/make/truenas.makefile b/.gitlab/make/truenas.makefile new file mode 100644 index 0000000..52feb62 --- /dev/null +++ b/.gitlab/make/truenas.makefile @@ -0,0 +1,5 @@ +.PHONY: chart-release +chart-release: + @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 diff --git a/Makefile b/Makefile index c114817..996a6d2 100644 --- a/Makefile +++ b/Makefile @@ -1 +1,13 @@ -include .common/Makefile +SHELL := /bin/bash + +include .gitlab/Makefile + +.PHONY: get-server +get-server: + @mkdir -p world + @echo 'eula=true' > world/eula.txt + @docker run -it -e SERVER_VERSION=1.17.1 -v $(PWD)/world:/downloads ducoterra/get-minecraft:latest + +.PHONY: run +run: + docker-compose run --service-ports minecraft diff --git a/README.md b/README.md index 7249982..81bb2a4 100644 --- a/README.md +++ b/README.md @@ -1,61 +1,34 @@ # Minecraft -## Getting server.jar - -![Click Installations](img/main.png) -![Select the Options Menu](img/menu.png) -![Click Edit](img/edit.png) -![Click Download Server](img/server.png) - ## Running Locally ```bash -docker-compose build minecraft -docker-compose up minecraft +# download the most recent version of minecraft +make get-server + +# Run the server +docker-compose up ``` ## Uploading to Docker Hub -In docker-compose.yaml, update the image tag to: +1. Update the version in the VERSION file. +2. Build and push the new version -```yaml -... -services: - minecraft: - build: . - image: /minecraft:-1 - ports: -... -``` - -then run - -```bash -docker-compose push -``` + ```bash + make build + make push + ``` ## Running in kubernetes -In k8s/deploy.yaml, edit the deploy - -```yaml -... - spec: - containers: - - name: minecraft - image: - ports: -... -``` - -Then run the following +Requires helm v3. Edit values.yaml and run the following: ```bash -kubectl apply -f k8s/pvc -kubectl apply -f k8s +helm upgrade --install minecraft ``` -Your minecraft server will be available on port 25565 +Your minecraft server will be available on port 25565 by default. ## Create a Backup diff --git a/VERSION b/VERSION index 3eefcb9..6d7de6e 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.0.0 +1.0.2 diff --git a/docker-compose.yaml b/docker-compose.yaml new file mode 100644 index 0000000..527768a --- /dev/null +++ b/docker-compose.yaml @@ -0,0 +1,13 @@ +version: '3' +services: + minecraft: + image: ducoterra/minecraft:1.0.2 + stdin_open: true + tty: true + volumes: + - ./world:/mc_data + ports: + - 25565:25565 + environment: + - MAX_RAM=1 + - MIN_RAM=1 diff --git a/helm/Chart.yaml b/helm/Chart.yaml index 6e2f7cd..f83145a 100644 --- a/helm/Chart.yaml +++ b/helm/Chart.yaml @@ -1,7 +1,6 @@ apiVersion: v2 name: minecraft description: A Minecraft server for kubernetes - # A chart can be either an 'application' or a 'library' chart. # # Application charts are a collection of templates that can be packaged into versioned archives @@ -11,13 +10,11 @@ description: A Minecraft server for kubernetes # a dependency of application charts to inject those utilities and functions into the rendering # pipeline. Library charts do not define any templates and therefore cannot be deployed. type: application - # This is the chart version. This version number should be incremented each time you make changes # to the chart and its templates, including the app version. # Versions are expected to follow Semantic Versioning (https://semver.org/) -version: 1.1.0 - +version: 1.0.2 # This is the version number of the application being deployed. This version number should be # incremented each time you make changes to the application. Versions are not expected to # follow Semantic Versioning. They should reflect the version the application is using. -appVersion: 1.0.0 +appVersion: 1.0.2 diff --git a/helm/templates/deploy.yaml b/helm/templates/deploy.yaml index e6a0c7e..a5872ad 100644 --- a/helm/templates/deploy.yaml +++ b/helm/templates/deploy.yaml @@ -23,13 +23,6 @@ spec: volumeMounts: - mountPath: /downloads name: data - - name: download-server - image: {{ .Values.get_server.image }} - imagePullPolicy: Always - command: ["bash", "-c", "curl -o server.jar $(cat SERVER_VERSION)"] - volumeMounts: - - mountPath: /downloads - name: data containers: - name: {{ .Release.Name }} image: {{ .Values.image }} diff --git a/helm/values.yaml b/helm/values.yaml index 01943f6..bb1d9ab 100644 --- a/helm/values.yaml +++ b/helm/values.yaml @@ -1,6 +1,6 @@ image: ducoterra/minecraft:latest get_server: - image: ducoterra/get-minecraft:latest + image: ducoterra/get-minecraft:2.0.0 server_version: "1.17.1" port: 20101 max_cpu: 4