From db2b6d66e3d2f01be4c401e94797da523f628ed7 Mon Sep 17 00:00:00 2001 From: ducoterra Date: Mon, 13 Dec 2021 15:14:25 -0500 Subject: [PATCH] Squashed '.gitlab/' changes from fe577bf..465f46a 465f46a Merge branch 'add-docker-compose-targets' into 'main' f6aed2c add docker-compose init, up, and down targets 88716ad populate default values for VERSION and IMAGE file when docker-init is run 16ee2f3 Merge branch 'various-docker-fixes' into 'main' 5b3e196 fix docker build and remove release 4bf9d45 Merge branch 'prefix-docker-commands' into 'main' 91b77b3 don't reset head after subtree pull, it breaks things 66b4362 prefix all docker commands with docker- ba2827a Merge branch 'allow-specify-branch' into 'main' 4de5558 ignore .gitlab 71ff227 Allow pulling specific branch with BRANCH_NAME 6430416 Merge branch 'add-helm-and-kube' into 'main' bce675f Add install, upgrade, and uninstall for helm 1532f30 Add kubectl.makefile cf41f2e Merge branch 'remove-push' into 'main' ef81c95 Remove unused commands 81c19cc Don't use remote common ea1e248 Update subtree add README 756cc8c Remove make-push a4b7e34 Squash subtree on pull 524c5be Fix PROJECT_NAME variable 47dea48 Add automated commit to chart-release REVERT: fe577bf remove old forge versions before unzipping REVERT: 6c4354d Automated release for version 1.0.1 REVERT: 6fd156e genericize the container run commands by normalizing file names REVERT: b776273 add update-version, remove get-server REVERT: 4488fbf move values to helm/values.yaml REVERT: dad1e4c sync versions to chart.yaml REVERT: a171258 remove truenas chart stuff REVERT: 84abbd4 Merge update from Common REVERT: a13cfe6 Squashed '.gitlab/' changes from 6430416..16ee2f3 REVERT: 8b0a8fa setenv is deprecated REVERT: 6213e7f pin FROM to use 8-jdk-bullseye REVERT: 9dc2f0e switch to correct image in docker-compose REVERT: b0991ea ignore versions folder where we keep pack zip files REVERT: f8fc83b remove default values REVERT: e2c677b add unzip and copy properties init container, don't mount properties REVERT: d118b2d add the-1122-pack values REVERT: a280110 Squashed '.gitlab/' changes from cf41f2e..6430416 REVERT: 6d11fde Merge update from Common REVERT: 4497566 Squashed '.gitlab/' changes from 731ada6..cf41f2e REVERT: 0520668 Merge update from Common REVERT: 2de53de Remove .common REVERT: a85a7aa Merge branch 'common-subtree' REVERT: a074005 Add '.gitlab/' from commit '731ada6a3d65b2347ccf204cfe09ee278a4f0594' REVERT: 422f4d4 remove .gitlab subtree REVERT: a5aa0ca Automated release for version 1.0.2 REVERT: 65b3a84 make subtree "split" overhaul REVERT: d181d45 Overhaul for get-server v. 2.0.0 REVERT: 0d2235b Merge branch 'common-makefile' into 'master' REVERT: dbe0d47 Merge branch 'master' into 'common-makefile' REVERT: c7c547c Switch to common Makefile REVERT: a403f6f Merge commit '32cd04c7ec7aacf8e3a402e3aed310a6ea94b586' as '.common' REVERT: 32cd04c Squashed '.common/' content from commit f187522 REVERT: 8d190e4 Add minecraft logo REVERT: ba5ab53 Allow custom server versions REVERT: a820e9a Allow custom server versions REVERT: 9e788ee Add IMAGE and VERSION files REVERT: d3b0f86 Switch to openjdk-latest and don't copy server.jar REVERT: 2f7d4c7 Add Makefile REVERT: aa253e6 Remove server.jar and docker-compose.yaml REVERT: 773c1d6 Move install-specific values to a values folder REVERT: dae5a09 Fix RAM issue with deploy REVERT: 44053ab truenas compatibility update REVERT: 807b186 set memory requirements to avoid sudden container death REVERT: 99666ba add setenv REVERT: 1b6b8bb update RAM for new cluster REVERT: 95c7fa7 merge templates REVERT: 7e0ff9e upgrade to 1.6.4 REVERT: 12fa8ec remove extra opts and remove threading REVERT: 7d34b3a add charts for each server REVERT: 95b0bd6 switch to configmap model REVERT: ff2c9af servers to nvme REVERT: 1dfb1f6 nvme for minecraft REVERT: 3faf5c9 don't auto deploy REVERT: 072bee6 update to 1.16.1 REVERT: e6a0429 fix port issue REVERT: 7df518d set image REVERT: ca4d1ee use tag in deploy REVERT: 1ccc5cd fix tags REVERT: 3ce71a6 add gitlab ci REVERT: 151867f switch back to minecraft 1.15.2 REVERT: abc90be add images REVERT: b727538 upgrade to 20w12a REVERT: 17b0594 upgrade to 20w12a REVERT: 9929e5d upgrade to 20w12a REVERT: 00386c7 just copy files to mc_data REVERT: 0c75d91 switch to ducoterra namespace REVERT: 8bdae44 add README for backups REVERT: 6264d75 set namespace to minecraft REVERT: f59775d use a loadbalancer REVERT: e54fdbe update IP REVERT: 22987e0 comment horrible CMD REVERT: 38b9dff add server.properties and update k8s with ram env REVERT: da7cb2c add ram env REVERT: 53e37ba switch to java 8 and only copy files that exist REVERT: 0253598 add build script REVERT: 095bbaa init git-subtree-dir: .gitlab git-subtree-split: 465f46ad48404c13c25d7e9a961d7a4ce7ee997a --- .gitignore | 4 +- .gitlab-ci.yml | 21 ------- .gitlab/.gitignore | 1 - .gitlab/Makefile | 21 ------- .gitlab/README.md | 9 --- Dockerfile | 14 ----- IMAGE | 1 - Makefile | 32 +++++----- README.md | 54 ++--------------- VERSION | 1 - docker-compose.yaml | 13 ---- helm/.helmignore | 23 ------- helm/Chart.yaml | 20 ------- helm/templates/configmap.yaml | 8 --- helm/templates/deploy.yaml | 80 ------------------------- helm/templates/pvc.yaml | 12 ---- helm/templates/service.yaml | 12 ---- helm/values.yaml | 42 ------------- {.gitlab/make => make}/docker.makefile | 18 +++++- {.gitlab/make => make}/git.makefile | 0 {.gitlab/make => make}/helm.makefile | 0 {.gitlab/make => make}/kaniko.makefile | 0 {.gitlab/make => make}/kubectl.makefile | 0 {.gitlab/make => make}/truenas.makefile | 0 servers.md | 19 ------ 25 files changed, 39 insertions(+), 366 deletions(-) delete mode 100644 .gitlab-ci.yml delete mode 100644 .gitlab/.gitignore delete mode 100644 .gitlab/Makefile delete mode 100644 .gitlab/README.md delete mode 100644 Dockerfile delete mode 100644 IMAGE delete mode 100644 VERSION delete mode 100644 docker-compose.yaml delete mode 100644 helm/.helmignore delete mode 100644 helm/Chart.yaml delete mode 100644 helm/templates/configmap.yaml delete mode 100644 helm/templates/deploy.yaml delete mode 100644 helm/templates/pvc.yaml delete mode 100644 helm/templates/service.yaml delete mode 100644 helm/values.yaml rename {.gitlab/make => make}/docker.makefile (59%) rename {.gitlab/make => make}/git.makefile (100%) rename {.gitlab/make => make}/helm.makefile (100%) rename {.gitlab/make => make}/kaniko.makefile (100%) rename {.gitlab/make => make}/kubectl.makefile (100%) rename {.gitlab/make => make}/truenas.makefile (100%) delete mode 100644 servers.md diff --git a/.gitignore b/.gitignore index ad8082c..3bbaaed 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1 @@ -data/ -world/ -versions/ +.gitlab diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml deleted file mode 100644 index 1abb03c..0000000 --- a/.gitlab-ci.yml +++ /dev/null @@ -1,21 +0,0 @@ -variables: - CI_PROJECT_NAME: "minecraft" - CI_PROJECT_DIR: "." - CI_REGISTRY_IMAGE: hub.ducoterra.net/ducoterra/minecraft - -stages: - - build - - test - - deploy - -build: - only: - variables: - - $CI_COMMIT_TAG - stage: build - image: - name: gcr.io/kaniko-project/executor:debug - entrypoint: [""] - script: - - echo $DEPLOY - - /kaniko/executor --context $CI_PROJECT_DIR --dockerfile $CI_PROJECT_DIR/Dockerfile --destination $CI_REGISTRY_IMAGE:$CI_COMMIT_TAG \ No newline at end of file diff --git a/.gitlab/.gitignore b/.gitlab/.gitignore deleted file mode 100644 index 3bbaaed..0000000 --- a/.gitlab/.gitignore +++ /dev/null @@ -1 +0,0 @@ -.gitlab diff --git a/.gitlab/Makefile b/.gitlab/Makefile deleted file mode 100644 index f5ca9c1..0000000 --- a/.gitlab/Makefile +++ /dev/null @@ -1,21 +0,0 @@ -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" -MAKE_BRANCH ?= main - -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 -include .gitlab/make/kubectl.makefile - -# git subtree add --prefix .gitlab --squash --message "Merge update from Common" -q git@gitlab.ducoterra.net:services/common.git main -.PHONY: make-update -make-update: - @git subtree pull --prefix .gitlab --squash --message "Merge update from Common" -q git@gitlab.ducoterra.net:services/common.git $(MAKE_BRANCH) diff --git a/.gitlab/README.md b/.gitlab/README.md deleted file mode 100644 index 5680c6b..0000000 --- a/.gitlab/README.md +++ /dev/null @@ -1,9 +0,0 @@ -# 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/Dockerfile b/Dockerfile deleted file mode 100644 index 0d12498..0000000 --- a/Dockerfile +++ /dev/null @@ -1,14 +0,0 @@ -FROM openjdk:8-jdk-bullseye - -RUN apt update && apt install -y unzip - -RUN groupadd -r minecraft -g 2000 -RUN useradd --no-log-init minecraft -u 2000 -g 2000 -m -WORKDIR /mc_data -RUN chown -R minecraft:minecraft . - -# Copy the modpack -COPY versions/the-1122-pack_1.3.7.1.zip /the-1122-pack/the-1122-pack.zip -RUN chown -R minecraft:minecraft /the-1122-pack - -USER minecraft diff --git a/IMAGE b/IMAGE deleted file mode 100644 index 30eb29f..0000000 --- a/IMAGE +++ /dev/null @@ -1 +0,0 @@ -ducoterra/the-1122-pack diff --git a/Makefile b/Makefile index 29f2834..f5ca9c1 100644 --- a/Makefile +++ b/Makefile @@ -1,19 +1,21 @@ SHELL := /bin/bash -include .gitlab/Makefile +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" +MAKE_BRANCH ?= main -.PHONY: run -run: - docker-compose run --service-ports minecraft +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 +include .gitlab/make/kubectl.makefile -.PHONY: update-version -update-version: -ifdef VERSION - @echo $(VERSION) > VERSION - @yq e ".version = \"$(VERSION)\"" -i helm/Chart.yaml - @yq e ".appVersion = \"$(VERSION)\"" -i helm/Chart.yaml - @yq e ".services.*.image = \"$(IMAGE)\"" -i docker-compose.yaml - @yq e ".image = \"$(IMAGE)\"" -i helm/values.yaml -else - @echo 'VERSION not defined or VERSION file not found/empty' -endif +# git subtree add --prefix .gitlab --squash --message "Merge update from Common" -q git@gitlab.ducoterra.net:services/common.git main +.PHONY: make-update +make-update: + @git subtree pull --prefix .gitlab --squash --message "Merge update from Common" -q git@gitlab.ducoterra.net:services/common.git $(MAKE_BRANCH) diff --git a/README.md b/README.md index 81bb2a4..5680c6b 100644 --- a/README.md +++ b/README.md @@ -1,53 +1,9 @@ -# Minecraft - -## Running Locally +# Adding the "common" subtree as your .gitlab folder ```bash -# download the most recent version of minecraft -make get-server +# 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" -# Run the server -docker-compose up +# Now you can run the following to update +make make-update ``` - -## Uploading to Docker Hub - -1. Update the version in the VERSION file. -2. Build and push the new version - - ```bash - make build - make push - ``` - -## Running in kubernetes - -Requires helm v3. Edit values.yaml and run the following: - -```bash -helm upgrade --install minecraft -``` - -Your minecraft server will be available on port 25565 by default. - -## Create a Backup - -```bash -kubectl cp :/mc_data -``` - -## Restore from Backup - -```bash -kubectl cp :/mc_data -``` - -## Cool seeds - -### 7485786574821478084 - -Spawns you next to a nether portal with golden axe and pickaxe. River and Village close by. - -### -8018833100564192815 - -Use with an amplified world, massive island diff --git a/VERSION b/VERSION deleted file mode 100644 index 7dea76e..0000000 --- a/VERSION +++ /dev/null @@ -1 +0,0 @@ -1.0.1 diff --git a/docker-compose.yaml b/docker-compose.yaml deleted file mode 100644 index f631875..0000000 --- a/docker-compose.yaml +++ /dev/null @@ -1,13 +0,0 @@ -version: '3' -services: - minecraft: - image: ducoterra/the-1122-pack:1.0.1 - stdin_open: true - tty: true - volumes: - - ./world:/mc_data - ports: - - 25565:25565 - environment: - - MAX_RAM=1 - - MIN_RAM=1 diff --git a/helm/.helmignore b/helm/.helmignore deleted file mode 100644 index 0e8a0eb..0000000 --- a/helm/.helmignore +++ /dev/null @@ -1,23 +0,0 @@ -# Patterns to ignore when building packages. -# This supports shell glob matching, relative path matching, and -# negation (prefixed with !). Only one pattern per line. -.DS_Store -# Common VCS dirs -.git/ -.gitignore -.bzr/ -.bzrignore -.hg/ -.hgignore -.svn/ -# Common backup files -*.swp -*.bak -*.tmp -*.orig -*~ -# Various IDEs -.project -.idea/ -*.tmproj -.vscode/ diff --git a/helm/Chart.yaml b/helm/Chart.yaml deleted file mode 100644 index 5815e8d..0000000 --- a/helm/Chart.yaml +++ /dev/null @@ -1,20 +0,0 @@ -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 -# to be deployed. -# -# Library charts provide useful utilities or functions for the chart developer. They're included as -# 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.0.1 -# 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.1 diff --git a/helm/templates/configmap.yaml b/helm/templates/configmap.yaml deleted file mode 100644 index 43a784a..0000000 --- a/helm/templates/configmap.yaml +++ /dev/null @@ -1,8 +0,0 @@ -apiVersion: v1 -kind: ConfigMap -metadata: - name: {{ .Release.Name }} -data: - eula.txt: | - eula=true - server.properties: {{ toYaml .Values.server_props | indent 2 }} \ No newline at end of file diff --git a/helm/templates/deploy.yaml b/helm/templates/deploy.yaml deleted file mode 100644 index 075e755..0000000 --- a/helm/templates/deploy.yaml +++ /dev/null @@ -1,80 +0,0 @@ -apiVersion: apps/v1 -kind: Deployment -metadata: - name: {{ .Release.Name }} -spec: - selector: - matchLabels: - app: {{ .Release.Name }} - strategy: - type: Recreate - template: - metadata: - labels: - app: {{ .Release.Name }} - spec: - initContainers: - - name: unzip - image: {{ .Values.image }} - imagePullPolicy: Always - command: ["/bin/bash"] - args: ["-c", "rm -f forge*.jar && unzip -o -d . /the-1122-pack/the-1122-pack.zip"] - volumeMounts: - - mountPath: /mc_data - name: data - - name: rename - image: {{ .Values.image }} - imagePullPolicy: Always - command: ["/bin/bash"] - args: ["-c", "mv $(find . -maxdepth 1 -name 'forge*.jar') forge.jar"] - volumeMounts: - - mountPath: /mc_data - name: data - - name: copy-properties - image: debian:latest - imagePullPolicy: Always - command: ["/bin/bash"] - args: ["-c", "cp -f /server.properties /mc_data/server.properties"] - volumeMounts: - - mountPath: /mc_data - name: data - - name: properties - mountPath: /server.properties - subPath: server.properties - containers: - - name: server - image: {{ .Values.image }} - imagePullPolicy: Always - command: ["/bin/bash"] - args: ["-c", 'java -server -Xmx"$MAX_RAM"G -Dfml.queryResult=confirm -jar forge.jar nogui'] - ports: - - containerPort: 25565 - volumeMounts: - - mountPath: /mc_data - name: data - - name: properties - mountPath: /mc_data/eula.txt - subPath: eula.txt - tty: true - stdin: true - env: - - name: MAX_RAM - value: {{ .Values.max_ram | quote }} - - name: MIN_RAM - value: "1" - resources: - requests: - memory: {{ div .Values.max_ram 2 }}Gi - cpu: 1m - limits: - memory: {{ add 1 .Values.max_ram }}Gi - cpu: {{ .Values.max_cpu | quote }} - volumes: - - name: data - persistentVolumeClaim: - claimName: {{ .Release.Name }} - - name: properties - configMap: - name: {{ .Release.Name }} - securityContext: - fsGroup: 2000 diff --git a/helm/templates/pvc.yaml b/helm/templates/pvc.yaml deleted file mode 100644 index e825a00..0000000 --- a/helm/templates/pvc.yaml +++ /dev/null @@ -1,12 +0,0 @@ -apiVersion: v1 -kind: PersistentVolumeClaim -metadata: - name: {{ .Release.Name }} - annotations: - "helm.sh/resource-policy": keep -spec: - accessModes: - - ReadWriteOnce - resources: - requests: - storage: 32Gi \ No newline at end of file diff --git a/helm/templates/service.yaml b/helm/templates/service.yaml deleted file mode 100644 index eade03e..0000000 --- a/helm/templates/service.yaml +++ /dev/null @@ -1,12 +0,0 @@ -apiVersion: v1 -kind: Service -metadata: - name: {{ .Release.Name }} -spec: - selector: - app: {{ .Release.Name }} - ports: - - port: {{ .Values.port }} - targetPort: 25565 - name: {{ .Release.Name }} - type: LoadBalancer \ No newline at end of file diff --git a/helm/values.yaml b/helm/values.yaml deleted file mode 100644 index 3d20259..0000000 --- a/helm/values.yaml +++ /dev/null @@ -1,42 +0,0 @@ -image: ducoterra/the-1122-pack:1.0.1 -port: 20102 -max_cpu: 4 -max_ram: 6 -server_props: | - max-tick-time=-1 - query.port=25565 - generator-settings= - force-gamemode=false - allow-nether=true - gamemode=0 - enable-query=true - player-idle-timeout=0 - difficulty=1 - spawn-monsters=true - op-permission-level=4 - pvp=true - snooper-enabled=true - level-type=BIOMESOP - hardcore=false - enable-command-block=false - max-players=10 - network-compression-threshold=256 - resource-pack-sha1= - max-world-size=29999984 - server-port=25565 - server-ip=0.0.0.0 - spawn-npcs=true - allow-flight=true - level-name=world - view-distance=24 - resource-pack= - spawn-animals=true - white-list=true - generate-structures=true - online-mode=true - max-build-height=256 - level-seed= - prevent-proxy-connections=false - use-native-transport=true - enable-rcon=false - motd=\u00A7lThe 1.12.2 Pack Server v1.3.7 diff --git a/.gitlab/make/docker.makefile b/make/docker.makefile similarity index 59% rename from .gitlab/make/docker.makefile rename to make/docker.makefile index 08fa671..f5151b7 100644 --- a/.gitlab/make/docker.makefile +++ b/make/docker.makefile @@ -1,7 +1,7 @@ .PHONY: docker-init docker-init: - @touch VERSION - @touch IMAGE + @echo "0.0.1" >> VERSION + @echo "$(PROJECT_NAME)" >> IMAGE .PHONY: docker-buildx-context docker-buildx-context: @@ -21,3 +21,17 @@ docker-push: @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_LATEST) + +.PHONY: docker-compose-init +docker-compose-init: + @touch docker-compose.yaml + @yq e ".version = \"3\"" -i docker-compose.yaml + @yq e ".services.main.image = \"$(IMAGE)\"" -i docker-compose.yaml + +.PHONY: docker-compose-up +docker-compose-up: + docker-compose up -d + +.PHONY: docker-compose-down +docker-compose-down: + docker-compose down diff --git a/.gitlab/make/git.makefile b/make/git.makefile similarity index 100% rename from .gitlab/make/git.makefile rename to make/git.makefile diff --git a/.gitlab/make/helm.makefile b/make/helm.makefile similarity index 100% rename from .gitlab/make/helm.makefile rename to make/helm.makefile diff --git a/.gitlab/make/kaniko.makefile b/make/kaniko.makefile similarity index 100% rename from .gitlab/make/kaniko.makefile rename to make/kaniko.makefile diff --git a/.gitlab/make/kubectl.makefile b/make/kubectl.makefile similarity index 100% rename from .gitlab/make/kubectl.makefile rename to make/kubectl.makefile diff --git a/.gitlab/make/truenas.makefile b/make/truenas.makefile similarity index 100% rename from .gitlab/make/truenas.makefile rename to make/truenas.makefile diff --git a/servers.md b/servers.md deleted file mode 100644 index 67a699d..0000000 --- a/servers.md +++ /dev/null @@ -1,19 +0,0 @@ -# Servers - -## Minecraft - -```bash -helm upgrade --install minecraft ./helm --set tag=1.15.2_7 --set port=25565 -``` - -## Pubcraft - -```bash -helm upgrade --install pubcraft ./helm --set tag=1.15.2_7 --set port=20100 -``` - -## TestCraft - -```bash -helm upgrade --install testcraft ./helm --set tag=1.16.1_2 --set port=25566 -```