6 Commits 408a40dea2 ... a36dee9351

Author SHA1 Message Date
  tarfeef101 a36dee9351 remove manual trigger for workflow 3 years ago
  Tareef D ee801c1e2b Make More Usable 3 years ago
  tarfeef101 798e3805ba more readme 3 years ago
  tarfeef101 ec5495a21e workflow that should work 3 years ago
  tarfeef101 b7cfb86d26 better paramaters, confirmed to run 3 years ago
  tarfeef101 1708ea15c3 first draft, but continue on a non-unstable pc, i hate my server sometimes 3 years ago
5 changed files with 52 additions and 10 deletions
  1. 3 0
      .dockerignore
  2. 29 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

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

@@ -0,0 +1,29 @@
+name: Check for new releases, and build
+
+on:
+  schedule:
+    - cron: '0 0 * * *'
+
+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: