diff --git a/.gitignore b/.gitignore deleted file mode 100644 index adbb97d..0000000 --- a/.gitignore +++ /dev/null @@ -1 +0,0 @@ -data/ \ No newline at end of file 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/Dockerfile b/Dockerfile deleted file mode 100644 index e401881..0000000 --- a/Dockerfile +++ /dev/null @@ -1,10 +0,0 @@ -FROM openjdk:latest - -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 . - -USER minecraft -# 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 diff --git a/IMAGE b/IMAGE deleted file mode 100644 index a26228d..0000000 --- a/IMAGE +++ /dev/null @@ -1 +0,0 @@ -ducoterra/minecraft diff --git a/Makefile b/Makefile index 207d74e..1575e0d 100644 --- a/Makefile +++ b/Makefile @@ -1 +1,10 @@ -include .gitlab/Makefile +SHELL := /bin/bash + +IMAGE ?= $(shell cat IMAGE):$(shell cat VERSION) +IMAGE_LATEST ?= $(shell cat IMAGE):latest +PWD ?= $(shell pwd) + +include .gitlab/make/docker.makefile +include .gitlab/make/helm.makefile +include .gitlab/make/kaniko.makefile +include .gitlab/make/truenas.makefile diff --git a/README.md b/README.md index 7249982..1d084b1 100644 --- a/README.md +++ b/README.md @@ -1,80 +1,10 @@ -# 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 +# Adding the "common" subtree as your .gitlab folder ```bash -docker-compose build minecraft -docker-compose up minecraft +# Add the subtree as a remote +git remote add common git@gitlab.ducoterra.net:services/common.git +git subtree add --prefix .gitlab common main + +# Now you can run the following to update +git subtree pull --prefix .gitlab common main ``` - -## Uploading to Docker Hub - -In docker-compose.yaml, update the image tag to: - -```yaml -... -services: - minecraft: - build: . - image: /minecraft:-1 - ports: -... -``` - -then run - -```bash -docker-compose push -``` - -## Running in kubernetes - -In k8s/deploy.yaml, edit the deploy - -```yaml -... - spec: - containers: - - name: minecraft - image: - ports: -... -``` - -Then run the following - -```bash -kubectl apply -f k8s/pvc -kubectl apply -f k8s -``` - -Your minecraft server will be available on port 25565 - -## 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 3eefcb9..0000000 --- a/VERSION +++ /dev/null @@ -1 +0,0 @@ -1.0.0 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 6e2f7cd..0000000 --- a/helm/Chart.yaml +++ /dev/null @@ -1,23 +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.1.0 - -# 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 diff --git a/helm/README.md b/helm/README.md deleted file mode 100644 index 0b3d699..0000000 --- a/helm/README.md +++ /dev/null @@ -1,3 +0,0 @@ -# Minecraft Server - -Creates a vanilla Minecraft server. diff --git a/helm/app-readme.md b/helm/app-readme.md deleted file mode 100644 index 0b3d699..0000000 --- a/helm/app-readme.md +++ /dev/null @@ -1,3 +0,0 @@ -# Minecraft Server - -Creates a vanilla Minecraft server. diff --git a/helm/ix_values.yaml b/helm/ix_values.yaml deleted file mode 100644 index 4648913..0000000 --- a/helm/ix_values.yaml +++ /dev/null @@ -1,2 +0,0 @@ -image: ducoterra/minecraft:latest -server_version: "1.17.1" diff --git a/helm/minecraft-logo.png b/helm/minecraft-logo.png deleted file mode 100644 index d9ada6f..0000000 Binary files a/helm/minecraft-logo.png and /dev/null differ diff --git a/helm/questions.yaml b/helm/questions.yaml deleted file mode 100644 index 0182ab7..0000000 --- a/helm/questions.yaml +++ /dev/null @@ -1,38 +0,0 @@ -groups: - - name: "Server Config" - description: "Minecraft Server Configuration" - - name: "Storage" - description: "Minecraft Server Storage" -questions: - - variable: server_version - description: "Server Version" - label: "Version" - group: "Server Config" - schema: - type: string - default: "1.17.1" - required: false - - variable: port - description: "Listen Port" - group: "Server Config" - label: "Port" - schema: - type: int - default: 25565 - required: true - - variable: max_ram - description: "Total RAM allocated to the server" - group: "Server Config" - label: "RAM Limit (GiB)" - schema: - type: int - default: 4 - required: true - - variable: max_cpu - description: "# CPU Cores Allocated to the server" - group: "Server Config" - label: "CPU Limit (# Cores)" - schema: - type: int - default: 4 - required: true 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 e6a0c7e..0000000 --- a/helm/templates/deploy.yaml +++ /dev/null @@ -1,70 +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: get-version - image: {{ .Values.get_server.image }} - imagePullPolicy: Always - env: - - name: SERVER_VERSION - value: {{ .Values.server_version }} - 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 }} - imagePullPolicy: Always - ports: - - containerPort: 25565 - volumeMounts: - - mountPath: /mc_data - name: data - - name: properties - mountPath: /mc_data/server.properties - subPath: server.properties - - 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 01943f6..0000000 --- a/helm/values.yaml +++ /dev/null @@ -1,45 +0,0 @@ -image: ducoterra/minecraft:latest -get_server: - image: ducoterra/get-minecraft:latest -server_version: "1.17.1" -port: 20101 -max_cpu: 4 -max_ram: 4 -server_props: | - max-tick-time=60000 - generator-settings= - force-gamemode=false - allow-nether=true - gamemode=0 - broadcast-console-to-ops=true - enable-query=false - player-idle-timeout=0 - difficulty=3 - spawn-monsters=true - op-permission-level=4 - pvp=true - snooper-enabled=true - level-type=default - hardcore=false - enable-command-block=false - max-players=20 - network-compression-threshold=256 - resource-pack-sha1= - max-world-size=29999984 - server-port=25565 - server-ip= - spawn-npcs=true - allow-flight=true - level-name=world - view-distance=32 - 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 - motd=This is gonna be interesting - enable-rcon=false diff --git a/make/docker.makefile b/make/docker.makefile new file mode 100644 index 0000000..fc07142 --- /dev/null +++ b/make/docker.makefile @@ -0,0 +1,22 @@ +.PHONY: docker-init +docker-init: + @touch VERSION + @touch IMAGE + +.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) diff --git a/make/helm.makefile b/make/helm.makefile new file mode 100644 index 0000000..f603af4 --- /dev/null +++ b/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/make/kaniko.makefile b/make/kaniko.makefile new file mode 100644 index 0000000..e69de29 diff --git a/make/truenas.makefile b/make/truenas.makefile new file mode 100644 index 0000000..c6fb58c --- /dev/null +++ b/make/truenas.makefile @@ -0,0 +1,3 @@ +.PHONY: chart-release +chart-release: + @rsync -av $(CHART)/helm/ charts/$(CHART)/$(shell cat $(CHART)/VERSION)/ 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 -``` diff --git a/setenv.sh b/setenv.sh deleted file mode 100755 index a6290aa..0000000 --- a/setenv.sh +++ /dev/null @@ -1 +0,0 @@ -kubectl config set current-context k3os-alpha.dnet-ducoterra-minecraft \ No newline at end of file diff --git a/values/values-camcraft.yaml b/values/values-camcraft.yaml deleted file mode 100644 index da74c4b..0000000 --- a/values/values-camcraft.yaml +++ /dev/null @@ -1,42 +0,0 @@ -image: hub.ducoterra.net/ducoterra/minecraft:1.16.4 -port: 20101 -max_cpu: 8 -max_ram: 8 -server_props: | - max-tick-time=60000 - generator-settings= - force-gamemode=false - allow-nether=true - gamemode=0 - broadcast-console-to-ops=true - enable-query=false - player-idle-timeout=0 - difficulty=3 - spawn-monsters=true - op-permission-level=4 - pvp=true - snooper-enabled=true - level-type=default - hardcore=false - enable-command-block=false - max-players=20 - network-compression-threshold=256 - resource-pack-sha1= - max-world-size=29999984 - server-port=25565 - server-ip= - spawn-npcs=true - allow-flight=true - level-name=world - view-distance=32 - 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 - motd=This is gonna be interesting - enable-rcon=false diff --git a/values/values-minecraft.yaml b/values/values-minecraft.yaml deleted file mode 100644 index f06240a..0000000 --- a/values/values-minecraft.yaml +++ /dev/null @@ -1,42 +0,0 @@ -image: hub.ducoterra.net/ducoterra/minecraft:1.16.4 -port: 25565 -max_cpu: 8 -max_ram: 6 -server_props: | - max-tick-time=60000 - generator-settings= - force-gamemode=false - allow-nether=true - gamemode=0 - broadcast-console-to-ops=true - enable-query=false - player-idle-timeout=0 - difficulty=3 - spawn-monsters=true - op-permission-level=4 - pvp=true - snooper-enabled=true - level-type=default - hardcore=false - enable-command-block=false - max-players=20 - network-compression-threshold=256 - resource-pack-sha1= - max-world-size=29999984 - server-port=25565 - server-ip= - spawn-npcs=true - allow-flight=true - level-name=world - view-distance=32 - 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 - motd=This is gonna be interesting - enable-rcon=false \ No newline at end of file diff --git a/values/values-pubcraft.yaml b/values/values-pubcraft.yaml deleted file mode 100644 index 5b5583d..0000000 --- a/values/values-pubcraft.yaml +++ /dev/null @@ -1,42 +0,0 @@ -image: hub.ducoterra.net/ducoterra/minecraft:1.16.4 -port: 20100 -max_cpu: 8 -max_ram: 6 -server_props: | - max-tick-time=60000 - generator-settings= - force-gamemode=false - allow-nether=true - gamemode=0 - broadcast-console-to-ops=true - enable-query=false - player-idle-timeout=0 - difficulty=3 - spawn-monsters=true - op-permission-level=4 - pvp=true - snooper-enabled=true - level-type=default - hardcore=false - enable-command-block=false - max-players=20 - network-compression-threshold=256 - resource-pack-sha1= - max-world-size=29999984 - server-port=25565 - server-ip= - spawn-npcs=true - allow-flight=true - level-name=world - view-distance=32 - 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 - motd=This is gonna be interesting - enable-rcon=false \ No newline at end of file diff --git a/values/values-testcraft.yaml b/values/values-testcraft.yaml deleted file mode 100644 index 38f3966..0000000 --- a/values/values-testcraft.yaml +++ /dev/null @@ -1,42 +0,0 @@ -image: hub.ducoterra.net/ducoterra/minecraft:1.16.4 -port: 25566 -max_cpu: 8 -max_ram: 6 -server_props: | - max-tick-time=60000 - generator-settings= - force-gamemode=false - allow-nether=true - gamemode=0 - broadcast-console-to-ops=true - enable-query=false - player-idle-timeout=0 - difficulty=3 - spawn-monsters=true - op-permission-level=4 - pvp=true - snooper-enabled=true - level-type=amplified - hardcore=false - enable-command-block=false - max-players=20 - network-compression-threshold=256 - resource-pack-sha1= - max-world-size=29999984 - server-port=25565 - server-ip= - spawn-npcs=true - allow-flight=true - level-name=world - view-distance=64 - resource-pack= - spawn-animals=true - white-list=true - generate-structures=true - online-mode=true - max-build-height=512 - level-seed= - prevent-proxy-connections=false - use-native-transport=true - motd=This is gonna be interesting - enable-rcon=false \ No newline at end of file