initial push
All checks were successful
Gitea Actions Demo / Explore-Gitea-Actions (push) Successful in 1m36s
All checks were successful
Gitea Actions Demo / Explore-Gitea-Actions (push) Successful in 1m36s
This commit is contained in:
commit
771700d6c8
1
.dockerignore
Normal file
1
.dockerignore
Normal file
@ -0,0 +1 @@
|
|||||||
|
data/
|
19
.gitea/workflows/test.yaml
Normal file
19
.gitea/workflows/test.yaml
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
name: Gitea Actions Demo
|
||||||
|
run-name: ${{ gitea.actor }} is testing out Gitea Actions 🚀
|
||||||
|
on: [push]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
Explore-Gitea-Actions:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- run: echo "🎉 The job was automatically triggered by a ${{ gitea.event_name }} event."
|
||||||
|
- run: echo "🐧 This job is now running on a ${{ runner.os }} server hosted by Gitea!"
|
||||||
|
- run: echo "🔎 The name of your branch is ${{ gitea.ref }} and your repository is ${{ gitea.repository }}."
|
||||||
|
- name: Check out repository code
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
- run: echo "💡 The ${{ gitea.repository }} repository has been cloned to the runner."
|
||||||
|
- run: echo "🖥️ The workflow is now ready to test your code on the runner."
|
||||||
|
- name: List files in the repository
|
||||||
|
run: |
|
||||||
|
ls ${{ gitea.workspace }}
|
||||||
|
- run: echo "🍏 This job's status is ${{ job.status }}."
|
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
data/
|
32
Dockerfile
Normal file
32
Dockerfile
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
FROM ubuntu:noble
|
||||||
|
|
||||||
|
ENV DEBIAN_FRONTEND=noninteractive
|
||||||
|
|
||||||
|
# install prerequisites
|
||||||
|
RUN apt update \
|
||||||
|
&& apt install -y --no-install-recommends \
|
||||||
|
curl ca-certificates \
|
||||||
|
jq \
|
||||||
|
libxml2-utils \
|
||||||
|
&& apt autoremove \
|
||||||
|
&& apt clean \
|
||||||
|
&& rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
|
# Remove default ubuntu user
|
||||||
|
RUN userdel -r ubuntu \
|
||||||
|
&& useradd --create-home -u 1000 minecraft \
|
||||||
|
&& mkdir -p /data \
|
||||||
|
&& chown -R 1000:1000 /data
|
||||||
|
|
||||||
|
USER minecraft
|
||||||
|
|
||||||
|
RUN curl -sL https://github.com/Jabba-Team/jabba/raw/main/install.sh | bash \
|
||||||
|
&& . ~/.jabba/jabba.sh
|
||||||
|
|
||||||
|
USER root
|
||||||
|
|
||||||
|
COPY ./scripts/init /
|
||||||
|
COPY ./scripts/mc /usr/local/bin
|
||||||
|
RUN chmod +x /init && chmod +x /usr/local/bin/mc
|
||||||
|
|
||||||
|
CMD ["/init"]
|
24
compose.yaml
Normal file
24
compose.yaml
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
services:
|
||||||
|
minecraftTest:
|
||||||
|
image: minecraft:test
|
||||||
|
container_name: minecraftTest
|
||||||
|
stdin_open: true
|
||||||
|
tty: true
|
||||||
|
environment:
|
||||||
|
- MC_LOADER=forge
|
||||||
|
- MC_VERSION=1.21.4
|
||||||
|
- JAVA_VERSION=temurin@21
|
||||||
|
- JAR=server.jar
|
||||||
|
- MEM=2G
|
||||||
|
- ADD_ARGS=
|
||||||
|
- RESTART=true
|
||||||
|
build:
|
||||||
|
dockerfile: Dockerfile
|
||||||
|
context: .
|
||||||
|
volumes:
|
||||||
|
- ./data:/data
|
||||||
|
deploy:
|
||||||
|
resources:
|
||||||
|
limits:
|
||||||
|
memory: 2G
|
||||||
|
restart: unless-stopped
|
16
scripts/init
Normal file
16
scripts/init
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
#!/bin/env bash
|
||||||
|
|
||||||
|
PUID="${PUID:-1000}"
|
||||||
|
PGID="${PGID:-1000}"
|
||||||
|
|
||||||
|
setperms(){
|
||||||
|
echo "Setting permissions to UID:${PUID} and GID:${PGID}"
|
||||||
|
usermod -u ${PUID} minecraft > /dev/null 2>&1
|
||||||
|
groupmod -g ${PGID} minecraft > /dev/null 2>&1
|
||||||
|
chown -R ${PUID}:${PGID} /data > /dev/null 2>&1
|
||||||
|
sleep 2
|
||||||
|
}
|
||||||
|
|
||||||
|
setperms
|
||||||
|
|
||||||
|
su -c "mc" minecraft
|
160
scripts/mc
Normal file
160
scripts/mc
Normal file
@ -0,0 +1,160 @@
|
|||||||
|
#!/bin/env bash
|
||||||
|
|
||||||
|
MC_LOADER="${MC_LOADER:="paper"}"
|
||||||
|
MC_VERSION=${MC_VERSION:="1.21.4"}
|
||||||
|
|
||||||
|
JAVA_VERSION=${JAVA_VERSION:="temurin@21"}
|
||||||
|
JAR=${JAR:="server.jar"}
|
||||||
|
MEM=${MEMORY:=2G}
|
||||||
|
ADD_ARGS=${ADD_ARGS:=""}
|
||||||
|
|
||||||
|
RESTART=${RESTART:="true"}
|
||||||
|
|
||||||
|
crash() {
|
||||||
|
sleep 5
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
setEula() {
|
||||||
|
if [[ ! -s "eula.txt" ]]; then
|
||||||
|
echo "#By changing the setting below to TRUE you are indicating your agreement to our EULA (https://aka.ms/MinecraftEULA)." >eula.txt
|
||||||
|
echo "eula=true" >>eula.txt
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
javaCheck(){
|
||||||
|
JAVA_HOME=/data/java/${JAVA_VERSION}
|
||||||
|
if [[ -f "$HOME/.jabba/jabba.sh" ]]; then
|
||||||
|
source $HOME/.jabba/jabba.sh
|
||||||
|
else
|
||||||
|
echo "Something went wrong with locating jabba(the java installer)"
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ ! -n "${JAVA_VERSION}" ]]; then
|
||||||
|
echo "NO JAVA_VERSION ENVIRONMENT VARIABLE SET SET IT"
|
||||||
|
crash
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ ! -f "/data/java/${JAVA_VERSION}/bin/java" ]]; then
|
||||||
|
rm -rf /data/java/${JAVA_VERSION}
|
||||||
|
jabba install ${JAVA_VERSION} -o /data/java/${JAVA_VERSION}
|
||||||
|
fi
|
||||||
|
PATH=${JAVA_HOME}/bin:$PATH
|
||||||
|
JAVA="java"
|
||||||
|
}
|
||||||
|
|
||||||
|
getPaper() {
|
||||||
|
LATEST_BUILD=$(curl -s https://api.papermc.io/v2/projects/${MC_LOADER}/versions/${MC_VERSION}/builds |
|
||||||
|
jq -r '.builds | map(select(.channel == "default") | .build) | .[-1]')
|
||||||
|
|
||||||
|
if [ "$LATEST_BUILD" != "null" ]; then
|
||||||
|
JAR_NAME=${MC_LOADER}-${MC_VERSION}-${LATEST_BUILD}.jar
|
||||||
|
PAPERMC_URL="https://api.papermc.io/v2/projects/${MC_LOADER}/versions/${MC_VERSION}/builds/${LATEST_BUILD}/downloads/${JAR_NAME}"
|
||||||
|
|
||||||
|
# Download the latest Paper version
|
||||||
|
curl -o server.jar $PAPERMC_URL
|
||||||
|
echo "Download completed"
|
||||||
|
echo "Minecraft Version: ${MC_VERSION}"
|
||||||
|
echo "Paper Version: ${LATEST_BUILD}"
|
||||||
|
else
|
||||||
|
echo "No stable build for version $MC_VERSION found :("
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
getFabric(){
|
||||||
|
LATEST_BUILD=$(curl -s https://meta.fabricmc.net/v2/versions/loader/${MC_VERSION} | jq -s '.[] .[0] .loader .version' | tr -d '"')
|
||||||
|
LATEST_INSTALLER=$(curl -s https://maven.fabricmc.net/net/fabricmc/fabric-installer/maven-metadata.xml | xmllint --xpath "/metadata/versioning/latest/text()" -)
|
||||||
|
DL_URL=https://meta.fabricmc.net/v2/versions/loader/${MC_VERSION}/${LATEST_BUILD}/${LATEST_INSTALLER}/server/jar
|
||||||
|
if [ "$LATEST_BUILD" != "null" ]; then
|
||||||
|
echo "$DL_URL"
|
||||||
|
curl -o server.jar ${DL_URL}
|
||||||
|
else
|
||||||
|
echo "TODO ERROR TEXT"
|
||||||
|
fi
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
getForge(){
|
||||||
|
LATEST_BUILD=$(curl -s https://files.minecraftforge.net/net/minecraftforge/forge/promotions_slim.json | jq -r ".promos[\"${MC_VERSION}-latest\"]")
|
||||||
|
DL_BUILD=${MC_VERSION}-${LATEST_BUILD}
|
||||||
|
DL_URL=https://maven.minecraftforge.net/net/minecraftforge/forge/$DL_BUILD/forge-$DL_BUILD-installer.jar
|
||||||
|
if [ "$LATEST_BUILD" != "null" ]; then
|
||||||
|
echo "$DL_URL"
|
||||||
|
curl -o forge-install.jar ${DL_URL}
|
||||||
|
echo "$JAVA -jar forge-install.jar --installServer"
|
||||||
|
$JAVA -jar forge-install.jar --installServer
|
||||||
|
ln -s forge-${MC_VERSION}-${LATEST_BUILD}-shim.jar server.jar
|
||||||
|
touch server.properties
|
||||||
|
|
||||||
|
rm -f user_jvm_args.txt
|
||||||
|
rm -f forge-install.jar
|
||||||
|
rm -f forge-install.jar.log
|
||||||
|
rm -f README.txt
|
||||||
|
rm -f run.bat
|
||||||
|
rm -f run.sh
|
||||||
|
else
|
||||||
|
echo "TODO ERROR TEXT"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
serverSelect(){
|
||||||
|
mkdir -p /data/server
|
||||||
|
cd /data/server
|
||||||
|
if [[ ! -f server.jar ]]; then
|
||||||
|
case $MC_LOADER in
|
||||||
|
vanilla)
|
||||||
|
getVanilla
|
||||||
|
;;
|
||||||
|
paper)
|
||||||
|
getPaper
|
||||||
|
;;
|
||||||
|
fabric)
|
||||||
|
getFabric
|
||||||
|
;;
|
||||||
|
forge)
|
||||||
|
getForge
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
echo "Server of type ${MC_LOADER} is not recognized."
|
||||||
|
crash
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
buildCommand(){
|
||||||
|
JAVA_ARGS="-Xms${MEM} -Xmx${MEM}"
|
||||||
|
if [[ -z ${ADD_ARGS+x} ]]; then
|
||||||
|
RUN_STRING="${ADD_ARGS} ${JAVA_ARGS} -jar ${JAR} nogui"
|
||||||
|
else
|
||||||
|
RUN_STRING="${JAVA_ARGS} -jar ${JAR} nogui"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
runServer(){
|
||||||
|
setEula
|
||||||
|
while true; do
|
||||||
|
if [[ -f $JAR ]]; then
|
||||||
|
buildCommand
|
||||||
|
echo "${JAVA} ${RUN_STRING}"
|
||||||
|
$JAVA ${RUN_STRING}
|
||||||
|
else
|
||||||
|
echo "${JAR} not found."
|
||||||
|
fi
|
||||||
|
if [[ "${RESTART}" != "true" ]]; then
|
||||||
|
echo "Exiting..."
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
echo -e "\n${RD}Automatically restarting server in 5 seconds. Press CTRL + C to abort and exit.${NC}"
|
||||||
|
sleep 5
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
# ------------------------------------------------------------------------------- #
|
||||||
|
|
||||||
|
javaCheck
|
||||||
|
|
||||||
|
serverSelect
|
||||||
|
|
||||||
|
runServer
|
Loading…
x
Reference in New Issue
Block a user