Compare commits
13 Commits
8a78fd604a
...
openjdk11
Author | SHA1 | Date | |
---|---|---|---|
b4fc6a2654 | |||
7879f3b5e4 | |||
2e03a1faf8 | |||
bd2041a886 | |||
2fba83fd15 | |||
c50a4b4176 | |||
60943d2f82 | |||
c7328f43c2 | |||
0dd98315e5 | |||
5be6e30444 | |||
ed6fc1af16 | |||
df3c6166ac | |||
7bd0953dad |
@@ -3,3 +3,4 @@
|
|||||||
.gitignore
|
.gitignore
|
||||||
.gitlab-ci.yml
|
.gitlab-ci.yml
|
||||||
README.md
|
README.md
|
||||||
|
build.sh
|
||||||
|
@@ -10,14 +10,13 @@ variables:
|
|||||||
CI_PROJECT_NAME: minecraft-forge
|
CI_PROJECT_NAME: minecraft-forge
|
||||||
stages:
|
stages:
|
||||||
- build
|
- build
|
||||||
# - test
|
|
||||||
- push
|
|
||||||
services:
|
services:
|
||||||
- docker:dind
|
- docker:dind
|
||||||
before_script:
|
before_script:
|
||||||
- echo -n "$CI_LOGIN_PASSWORD" | docker login -u "$CI_LOGIN_USERNAME" --password-stdin
|
- echo -n "$CI_LOGIN_PASSWORD" | docker login -u "$CI_LOGIN_USERNAME" --password-stdin
|
||||||
- docker version
|
- docker version
|
||||||
- docker info
|
- docker info
|
||||||
|
- apk add bash
|
||||||
after_script:
|
after_script:
|
||||||
- docker logout hub.docker.com
|
- docker logout hub.docker.com
|
||||||
|
|
||||||
@@ -25,43 +24,4 @@ after_script:
|
|||||||
Build:
|
Build:
|
||||||
stage: build
|
stage: build
|
||||||
script:
|
script:
|
||||||
- docker pull $CI_HUB_USERNAME/$CI_PROJECT_NAME:latest || true
|
- bash build.sh
|
||||||
- docker buildx create --use
|
|
||||||
- >
|
|
||||||
docker buildx build
|
|
||||||
--pull
|
|
||||||
--platform linux/amd64
|
|
||||||
--cache-from $CI_HUB_USERNAME/$CI_PROJECT_NAME:latest
|
|
||||||
--tag $CI_HUB_USERNAME/$CI_PROJECT_NAME:$CI_COMMIT_SHORT_SHA
|
|
||||||
--push
|
|
||||||
.
|
|
||||||
- docker images
|
|
||||||
|
|
||||||
# PUSH
|
|
||||||
Push_When_Tag:
|
|
||||||
stage: push
|
|
||||||
only:
|
|
||||||
- tags
|
|
||||||
script:
|
|
||||||
- docker pull $CI_HUB_USERNAME/$CI_PROJECT_NAME:$CI_COMMIT_SHORT_SHA
|
|
||||||
- >
|
|
||||||
docker tag
|
|
||||||
$CI_HUB_USERNAME/$CI_PROJECT_NAME:$CI_COMMIT_SHORT_SHA
|
|
||||||
$CI_HUB_USERNAME/$CI_PROJECT_NAME:$CI_COMMIT_REF_NAME
|
|
||||||
- >
|
|
||||||
docker tag
|
|
||||||
$CI_HUB_USERNAME/$CI_PROJECT_NAME:$CI_COMMIT_SHORT_SHA
|
|
||||||
$CI_HUB_USERNAME/$CI_PROJECT_NAME:latest
|
|
||||||
- docker images
|
|
||||||
- docker push $CI_HUB_USERNAME/$CI_PROJECT_NAME:$CI_COMMIT_REF_NAME
|
|
||||||
- docker push $CI_HUB_USERNAME/$CI_PROJECT_NAME:latest
|
|
||||||
Push_Bleeding:
|
|
||||||
stage: push
|
|
||||||
script:
|
|
||||||
- docker pull $CI_HUB_USERNAME/$CI_PROJECT_NAME:$CI_COMMIT_SHORT_SHA
|
|
||||||
- >
|
|
||||||
docker tag
|
|
||||||
$CI_HUB_USERNAME/$CI_PROJECT_NAME:$CI_COMMIT_SHORT_SHA
|
|
||||||
$CI_HUB_USERNAME/$CI_PROJECT_NAME:bleeding
|
|
||||||
- docker images
|
|
||||||
- docker push $CI_HUB_USERNAME/$CI_PROJECT_NAME:bleeding
|
|
||||||
|
@@ -3,12 +3,12 @@ FROM alpine:latest AS build
|
|||||||
|
|
||||||
# Args
|
# Args
|
||||||
ARG MINECRAFT_VERSION="1.16.5"
|
ARG MINECRAFT_VERSION="1.16.5"
|
||||||
ARG FORGE_VERSION="36.1.4"
|
ARG FORGE_VERSION="36.2.22"
|
||||||
|
|
||||||
# The actual setup work
|
# The actual setup work
|
||||||
COPY start-server.sh /minecraft/start-server.sh
|
COPY start-server.sh /minecraft/start-server.sh
|
||||||
WORKDIR /minecraft
|
WORKDIR /minecraft
|
||||||
RUN apk add curl openjdk8-jre &&\
|
RUN apk add curl openjdk11-jre &&\
|
||||||
curl -L "https://files.minecraftforge.net/maven/net/minecraftforge/forge/${MINECRAFT_VERSION}-${FORGE_VERSION}/forge-${MINECRAFT_VERSION}-${FORGE_VERSION}-installer.jar" -o installer.jar &&\
|
curl -L "https://files.minecraftforge.net/maven/net/minecraftforge/forge/${MINECRAFT_VERSION}-${FORGE_VERSION}/forge-${MINECRAFT_VERSION}-${FORGE_VERSION}-installer.jar" -o installer.jar &&\
|
||||||
java -jar installer.jar --installServer &&\
|
java -jar installer.jar --installServer &&\
|
||||||
echo "eula=true" > eula.txt &&\
|
echo "eula=true" > eula.txt &&\
|
||||||
@@ -16,8 +16,8 @@ RUN apk add curl openjdk8-jre &&\
|
|||||||
ln -s "forge-${MINECRAFT_VERSION}-${FORGE_VERSION}.jar" server.jar
|
ln -s "forge-${MINECRAFT_VERSION}-${FORGE_VERSION}.jar" server.jar
|
||||||
|
|
||||||
# The second stage is the actual container
|
# The second stage is the actual container
|
||||||
FROM openjdk:8
|
FROM openjdk:11
|
||||||
RUN apt-get update && apt-get install rsync -y
|
RUN apt-get update && apt-get install rsync screen -y
|
||||||
WORKDIR /minecraft
|
WORKDIR /minecraft
|
||||||
COPY --from=build /minecraft .
|
COPY --from=build /minecraft .
|
||||||
CMD [ "bash", "start-server.sh" ]
|
CMD [ "bash", "start-server.sh" ]
|
||||||
|
15
README.md
15
README.md
@@ -7,10 +7,20 @@ A Dockerfile and some assorted scripts to build a Minecraft Forge server contain
|
|||||||
Deploy as expected:
|
Deploy as expected:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
docker run -p 25565:25565 rehashedsalt/minecraft-forge
|
docker run -p 25565:25565 rehashedsalt/minecraft-forge:1.16.5-36.1.4-1.0.0
|
||||||
```
|
```
|
||||||
|
|
||||||
And badda bing, badda boom, you'll have a Minecraft Forge server of whatever the latest stable is.
|
And badda bing, badda boom, you'll have a Minecraft Forge server of whatever the tag is.
|
||||||
|
|
||||||
|
The "latest" tag of each version of Minecraft is somewhere along the lines of "1.16.5-36.1.14-master". See Dockerhub for more info.
|
||||||
|
|
||||||
|
## Server Console
|
||||||
|
|
||||||
|
You can access the server console in a screen session pretty easily:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
docker exec -it mycontainer screen -r minecraft
|
||||||
|
```
|
||||||
|
|
||||||
## Application State
|
## Application State
|
||||||
|
|
||||||
@@ -29,6 +39,7 @@ variable|description
|
|||||||
`JRE_XMX`|Maximum amount of heap passed to the main Minecraft process
|
`JRE_XMX`|Maximum amount of heap passed to the main Minecraft process
|
||||||
`JRE_XMS`|Minimum heap size passed to the main Minecraft process
|
`JRE_XMS`|Minimum heap size passed to the main Minecraft process
|
||||||
`FORGE_PACK_ZIP`|If provided, the URL to a zip or tar.gz file that contains the modpack that needs to be installed. Will be intelligently extracted into the server directory through the magic of `find`.
|
`FORGE_PACK_ZIP`|If provided, the URL to a zip or tar.gz file that contains the modpack that needs to be installed. Will be intelligently extracted into the server directory through the magic of `find`.
|
||||||
|
`CONFIG_REPO`|If provided, the URI to a git repository that contains configuration to copy over top the pack. The root of the repo will be the root of the server directory.
|
||||||
`ARGS`|Any additional arguments to be passed to the JVM
|
`ARGS`|Any additional arguments to be passed to the JVM
|
||||||
|
|
||||||
## Useful Arguments
|
## Useful Arguments
|
||||||
|
31
build.sh
Executable file
31
build.sh
Executable file
@@ -0,0 +1,31 @@
|
|||||||
|
#! /bin/bash
|
||||||
|
#
|
||||||
|
# Build the Docker image for a series of different Forge versions
|
||||||
|
#
|
||||||
|
|
||||||
|
# MC version list
|
||||||
|
declare -a mcversions=(
|
||||||
|
"1.16.5"
|
||||||
|
)
|
||||||
|
|
||||||
|
# Forge version dictionary (we only support one version per)
|
||||||
|
declare -A forgeversions=(
|
||||||
|
["1.16.5"]="36.2.22"
|
||||||
|
)
|
||||||
|
|
||||||
|
# Build images
|
||||||
|
docker buildx create --use
|
||||||
|
for mc in ${mcversions[@]}; do
|
||||||
|
forge="${forgeversions[$mc]}"
|
||||||
|
echo "Building image for Minecraft $mc, Forge $forge, CI_COMMIT_REF_NAME of $CI_COMMIT_REF_NAME"
|
||||||
|
# --no-cache is required for clean builds
|
||||||
|
docker buildx build \
|
||||||
|
--build-arg MINECRAFT_VERSION="$mc" \
|
||||||
|
--build-arg FORGE_VERSION="$forge" \
|
||||||
|
--no-cache \
|
||||||
|
--platform linux/amd64 \
|
||||||
|
--tag "$CI_HUB_USERNAME/$CI_PROJECT_NAME:$mc-$forge-${CI_COMMIT_REF_NAME:=bleeding}" \
|
||||||
|
--push \
|
||||||
|
.
|
||||||
|
done
|
||||||
|
docker images
|
@@ -1,4 +1,4 @@
|
|||||||
#! /bin/sh
|
#! /bin/bash
|
||||||
#
|
#
|
||||||
# start-server.sh
|
# start-server.sh
|
||||||
# Copyright (C) 2021 Vintage Salt <rehashedsalt@cock.li>
|
# Copyright (C) 2021 Vintage Salt <rehashedsalt@cock.li>
|
||||||
@@ -16,7 +16,18 @@ if [ -n "$FORGE_PACK_ZIP" ]; then
|
|||||||
unzip pack.zip
|
unzip pack.zip
|
||||||
directory="$(find . -type d -iname "mods" -execdir pwd \; | sort -n | head -n 1)"
|
directory="$(find . -type d -iname "mods" -execdir pwd \; | sort -n | head -n 1)"
|
||||||
echo "Found modpack directory: $directory"
|
echo "Found modpack directory: $directory"
|
||||||
rsync -av "$directory"/ /minecraft/
|
rsync -av --ignore-existing "$directory"/ /minecraft/
|
||||||
|
popd > /dev/null 2>&1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Then also download and extract a config repo, if one exists
|
||||||
|
if [ -n "$CONFIG_REPO" ]; then
|
||||||
|
echo "Downloading config repo: $CONFIG_REPO"
|
||||||
|
tmpdir="$(mktemp -d)"
|
||||||
|
pushd "$tmpdir" > /dev/null 2>&1
|
||||||
|
git clone "$CONFIG_REPO" .
|
||||||
|
rm -rf .git
|
||||||
|
rsync -av --delete ./ /minecraft/
|
||||||
popd > /dev/null 2>&1
|
popd > /dev/null 2>&1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@@ -31,7 +42,15 @@ args="-jar server.jar nogui"
|
|||||||
# Debugging info
|
# Debugging info
|
||||||
java -version
|
java -version
|
||||||
echo "Invoking java with args: $args"
|
echo "Invoking java with args: $args"
|
||||||
|
echo
|
||||||
|
echo "To see the server console, execute this command in the container:"
|
||||||
|
echo " screen -r minecraft"
|
||||||
|
|
||||||
# Start 'er up
|
# Start 'er up
|
||||||
java $args
|
cleanup() {
|
||||||
|
screen -p 0 -S minecraft -X stuff save-all^M
|
||||||
|
screen -p 0 -S minecraft -X stuff stop^M
|
||||||
|
}
|
||||||
|
trap cleanup EXIT
|
||||||
|
screen -DmS minecraft java $args
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user