Browse Source

Make More Usable

Start building new versions
Make memory mgmt better
Make versioning easier
Newer java
More docs
Tareef D 2 years ago
parent
commit
ee801c1e2b
5 changed files with 53 additions and 10 deletions
  1. 3 0
      .dockerignore
  2. 30 0
      .github/workflows/check_for_new_and_build.yaml
  3. 5 5
      Dockerfile
  4. 8 1
      README.md
  5. 7 4
      docker-compose.yaml

+ 3 - 0
.dockerignore

@@ -0,0 +1,3 @@
+config/
+worlds/
+README.md

+ 30 - 0
.github/workflows/check_for_new_and_build.yaml

@@ -0,0 +1,30 @@
+name: Check for new releases, and build
+
+on:
+  schedule:
+    - cron: '0 0 * * *'
+  workflow_dispatch:
+
+jobs:
+  check_and_build:
+    name: Check for new releases, and build
+    runs-on: ubuntu-latest
+    steps:
+      - name: Checkout
+        uses: actions/checkout@v2
+
+      - name: Get latest version
+        run: |
+          curl -sSL https://launchermeta.mojang.com/mc/game/version_manifest.json | jq -r '.latest.release' > /tmp/version
+          echo "version=$(cat /tmp/version)" >> $GITHUB_ENV
+
+      - name: Build and push
+        env:
+          DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
+          DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
+          VERSION: ${{ env.version }}
+        run: |
+          echo "$DOCKER_PASSWORD" | docker login --username "$DOCKER_USERNAME" --password-stdin
+          docker-compose build --build-arg VERSION=$VERSION
+          docker tag tarfeef101/mc_java_vanilla:latest tarfeef101/mc_java_vanilla:$VERSION
+          docker push tarfeef101/mc_java_vanilla:$VERSION

+ 5 - 5
Dockerfile

@@ -1,16 +1,16 @@
-FROM openjdk:8-alpine
+FROM openjdk:18-alpine
 
 WORKDIR /opt/
 
-ENV MIN_MEM=1 MAX_MEM=16
+ENV MIN_MEM=512m MAX_MEM=4G
 
-ARG JAR=https://launcher.mojang.com/v1/objects/bb2b6b1aefcd70dfd1892149ac3a215f6c636b07/server.jar
+ARG VERSION=1.18.1
 
 # download+unpack & move configs to 1 folder
 # this allows for less volumes
 # ty @Roemer for the idea
 RUN apk add curl && \
-    curl -sSL $JAR -o server.jar && \
+    curl -sSL $(curl -sSL https://mcversions.net/download/${VERSION} | grep -o 'https://launcher.mojang.com.*server.jar') -o server.jar && \
     apk del curl && \
     echo "eula=true" > eula.txt && \
     mkdir config && \
@@ -21,4 +21,4 @@ RUN apk add curl && \
     ln -s config/banned-ips.json banned-ips.json && \
     ln -s config/banned-players.json banned-players.json
 
-CMD java -Xms${MIN_MEM}G -Xmx${MAX_MEM}G -jar server.jar nogui
+CMD java -Xms${MIN_MEM} -Xmx${MAX_MEM} -jar server.jar nogui

+ 8 - 1
README.md

@@ -3,6 +3,13 @@ This project is a simple dockerized environment in which to run a minecraft java
 
 The Docker Hub page can be found at [this link](https://hub.docker.com/repository/docker/tarfeef101/mc_java_vanilla).
 
+## Usage
+You should be able to run with a simple `docker-compose up -d`. However, you should first:
+- add your config files as described below
+- check the compose file and set your memory thresholds appropriately
+- check the compose file to set the image to the version you want.
+- potentially build if that image/version is not available
+
 ## Anatomy
 ```
 .
@@ -25,4 +32,4 @@ The Dockerfile tries to keep the image as simple and slim as possible. A slim ba
 This is the bind-mounted directory which will house your world data. This should be empty unless you have a pre-existing world you want to import. If you want to add resource packs, this is the place to put them.
 
 ## Building
-To build a new version, search for the JAR you're looking for at [MCVersions](https://mcversions.net/). Then, in the `docker-compose.yaml` file, set the `build` argument `JAR` to the URL of the file you wish to use. Then, run `docker-compose build` or `docker-compose up --build -d` (to just build, or build and start the server).
+To build a new version edit the `docker-compose.yaml` file, and set the `VERSION` argument to the version you wish to build. Then, run `docker-compose build` or `docker-compose up --build -d` (to just build, or build and start the server).

+ 7 - 4
docker-compose.yaml

@@ -2,13 +2,16 @@ version: '3'
 
 services:
   minecraft:
-    build: .
-      context:
+    build:
+      context: .
       args:
-        JAR: https://launcher.mojang.com/v1/objects/bb2b6b1aefcd70dfd1892149ac3a215f6c636b07/server.jar
-    image: mc_java_vanilla:alpine-1.15.2
+        VERSION: 1.18.1
+    image: tarfeef101/mc_java_vanilla:latest
     container_name: mc_java
     restart: on-failure
+    environment:
+      MIN_MEM: 512m
+      MAX_MEM: 2048m
     ports:
       - "8008:25565"
     volumes: