diff --git a/README.md b/README.md index a1df38b7ebe..54b15e54fd7 100644 --- a/README.md +++ b/README.md @@ -350,6 +350,33 @@ docker run -d -v /path/on/host:/data ... \ See the [Working with mods and plugins](#working-with-mods-and-plugins) section to set up Fabric mods and configuration. +### Running a Quilt Server + +Enable [Quilt server](https://quiltmc.org/) mode by adding a `-e TYPE=QUILT` to your command-line. + +``` +docker run -d -v /path/on/host:/data \ + -e TYPE=QUILT \ + -p 25565:25565 -e EULA=TRUE --name mc itzg/minecraft-server +``` + +By default, the container will install the latest [quilt server launcher](https://quiltmc.org/install/server/), using the latest [quilt-installer](https://github.com/QuiltMC/quilt-installer) against the minecraft version you have defined with `VERSION` (defaulting to the latest vanilla release of the game). + +A specific loader or installer version other than the latest can be requested using `QUILT_LOADER_VERSION` and `QUILT_INSTALLER_VERSION` respectively, such as: + +``` +docker run -d -v /path/on/host:/data ... \ + -e TYPE=QUILT \ + -e QUILT_LOADER_VERSION=0.16.0 \ + -e QUILT_INSTALLER_VERSION=0.4.1 +``` + +> If you wish to use an alternative launcher you can: +> * Provide the path to a custom launcher jar available to the container with `QUILT_LAUNCHER`, relative to `/data` (such as `-e QUILT_LAUNCHER=quilt-server-custom.jar`) +> * Provide the URL to a custom launcher jar with `QUILT_LAUNCHER_URL` (such as `-e QUILT_LAUNCHER_URL=http://HOST/quilt-server-custom.jar`) + +See the [Working with mods and plugins](#working-with-mods-and-plugins) section to set up Quilt mods and configuration. + ### Running a Bukkit/Spigot server Enable Bukkit/Spigot server mode by adding a `-e TYPE=BUKKIT` or `-e TYPE=SPIGOT` to your command-line. diff --git a/scripts/start-configuration b/scripts/start-configuration index 78082a96c0e..db6f2e62f88 100755 --- a/scripts/start-configuration +++ b/scripts/start-configuration @@ -176,6 +176,10 @@ case "${TYPE^^}" in exec "${SCRIPTS:-/}start-deployFabric" "$@" ;; + QUILT) + exec "${SCRIPTS:-/}start-deployQuilt" "$@" + ;; + FTBA) evaluateJavaCompatibilityForForge exec "${SCRIPTS:-/}start-deployFTBA" "$@" diff --git a/scripts/start-deployQuilt b/scripts/start-deployQuilt new file mode 100755 index 00000000000..ad46d248bf9 --- /dev/null +++ b/scripts/start-deployQuilt @@ -0,0 +1,60 @@ +#!/bin/bash +set -eu + +# shellcheck source=start-utils +. "${SCRIPTS:-/}start-utils" + +requireVar VANILLA_VERSION +export TYPE=QUILT +: "${QUILT_LAUNCHER:=}" +: "${QUILT_LAUNCHER_URL:=}" +: "${QUILT_INSTALLER_URL:=}" +: "${QUILT_INSTALLER_VERSION:=LATEST}" +: "${QUILT_LOADER_VERSION:=LATEST}" + +isDebugging && set -x + +# Custom quilt jar +if [[ $QUILT_LAUNCHER ]]; then + export SERVER=${QUILT_LAUNCHER} +# Custom quilt jar url +elif [[ $QUILT_LAUNCHER_URL ]]; then + export SERVER=quilt-server-$(echo -n "$QUILT_LAUNCHER_URL" | mc-image-helper hash) +# Official quilt installer +else + if [[ ${QUILT_INSTALLER_VERSION^^} = LATEST ]]; then + log "Checking Quilt Installer version information." + QUILT_INSTALLER_VERSION=$(maven-metadata-release https://maven.quiltmc.org/repository/release/org/quiltmc/quilt-installer/maven-metadata.xml) + fi + if [[ ${QUILT_LOADER_VERSION^^} = LATEST ]]; then + log "Checking Quilt Loader version information." + QUILT_LOADER_VERSION=$(maven-metadata-release https://maven.quiltmc.org/repository/release/org/quiltmc/quilt-loader/maven-metadata.xml) + fi + export INSTALLER=quilt-installer-${QUILT_INSTALLER_VERSION}.jar + export SERVER=quilt-server-${VANILLA_VERSION}-${QUILT_LOADER_VERSION}-launch.jar + export QUILT_INSTALLER_URL="https://maven.quiltmc.org/repository/release/org/quiltmc/quilt-installer/${QUILT_INSTALLER_VERSION}/quilt-installer-${QUILT_INSTALLER_VERSION}.jar" +fi + +if [[ ! -e ${SERVER} && ! -z ${QUILT_INSTALLER_URL} ]]; then + log "Downloading and installing $QUILT_INSTALLER_URL ..." + if ! get -o "$INSTALLER" "$QUILT_INSTALLER_URL"; then + log "Failed to download from given location $QUILT_INSTALLER_URL" + exit 2 + fi + if ! java -jar ${INSTALLER} install server ${VANILLA_VERSION} ${QUILT_LOADER_VERSION} --install-dir=./ --download-server; then + log "Failed to install $INSTALLER" + exit 2 + fi + if ! mv quilt-server-launch.jar ${SERVER}; then + log "Failed to rename $SERVER" + exit 2 + fi +fi + +if [[ ! -e ${SERVER} ]]; then + log "$SERVER does not exist, cannot launch server!" + exit 1 +fi + +export FAMILY=FABRIC +exec "${SCRIPTS:-/}start-setupWorld" "$@" diff --git a/tests/setuponlytests/quilt/docker-compose.yml b/tests/setuponlytests/quilt/docker-compose.yml new file mode 100644 index 00000000000..60c2aa3901a --- /dev/null +++ b/tests/setuponlytests/quilt/docker-compose.yml @@ -0,0 +1,13 @@ +version: "3" + +services: + mc: + restart: "no" + image: ${IMAGE_TO_TEST:-itzg/minecraft-server} + environment: + EULA: "TRUE" + SETUP_ONLY: "TRUE" + TYPE: QUILT + VERSION: ${MINECRAFT_VERSION:-LATEST} + volumes: + - ./data:/data diff --git a/tests/setuponlytests/quilt/require.sh b/tests/setuponlytests/quilt/require.sh new file mode 100644 index 00000000000..65b61c6c8dd --- /dev/null +++ b/tests/setuponlytests/quilt/require.sh @@ -0,0 +1 @@ +[[ $MINECRAFT_VERSION == LATEST ]] || exit 1 diff --git a/tests/setuponlytests/quilt/verify.sh b/tests/setuponlytests/quilt/verify.sh new file mode 100644 index 00000000000..0a85809413b --- /dev/null +++ b/tests/setuponlytests/quilt/verify.sh @@ -0,0 +1 @@ +mc-image-helper assert fileExists "/data/quilt-server-*-launch.jar"