Skip to content

Commit

Permalink
Merge branch 'develop' into 'main'
Browse files Browse the repository at this point in the history
Docker and Webservice

See merge request Griefed/ServerPackCreator!621
Griefed committed Oct 15, 2024
2 parents 7292409 + 89b0cf0 commit 5caacd0
Showing 18 changed files with 77 additions and 78 deletions.
10 changes: 4 additions & 6 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -11,11 +11,9 @@ RUN \
dos2unix gradlew && chmod +x gradlew && \
sh gradlew -Pversion="$VERSION" \
build --info --full-stacktrace \
-x :serverpackcreator-api:test -x :serverpackcreator-app:test && \
wget -O zulu21.tar.gz https://cdn.azul.com/zulu/bin/zulu21.30.15-ca-jdk21.0.1-linux_x64.tar.gz && \
tar -xvf zulu21.tar.gz -C /tmp/serverpackcreator/java --strip-components=1
-x :serverpackcreator-api:test -x :serverpackcreator-app:test

FROM ghcr.io/linuxserver/baseimage-ubuntu:jammy-version-d74de700
FROM ghcr.io/linuxserver/baseimage-ubuntu:jammy-version-102276d2

ARG VERSION=dev

@@ -35,7 +33,8 @@ RUN \
echo "**** Bring system up to date ****" && \
apt-get update && apt-get upgrade -y && \
apt-get install -y \
libatomic1 && \
libatomic1 \
openjdk-21-jdk-headless && \
echo "**** Creating our folder(s) ****" && \
mkdir -p \
/app/serverpackcreator/java && \
@@ -47,7 +46,6 @@ RUN \
/tmp/*

COPY --chmod=777 root/ /
COPY --from=builder --chmod=777 /tmp/serverpackcreator/java/ /app/serverpackcreator/java
COPY --from=builder --chmod=777 /tmp/serverpackcreator/serverpackcreator-app/build/libs/serverpackcreator-app-$VERSION.jar /app/serverpackcreator/serverpackcreator.jar

EXPOSE 8080
8 changes: 5 additions & 3 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -9,10 +9,10 @@ services:
- POSTGRES_USER=<YOUR_USERNAME>
- POSTGRES_PASSWORD=<YOUR_PASSWORD>
volumes:
- ./database:/var/lib/postgresql/data
- database:/var/lib/postgresql/data
serverpackcreator:
container_name: serverpackcreator
image: serverpackcreator/serverpackcreator-dev
image: griefed/serverpackcreator:latest
restart: unless-stopped
depends_on:
- serverpackcreatordb
@@ -42,4 +42,6 @@ services:
volumes:
- ./modpacks:/app/serverpackcreator/modpacks
- ./server-packs:/app/serverpackcreator/server-packs
- ./logs:/app/serverpackcreator/logs
- ./logs:/app/serverpackcreator/logs
volumes:
database:
5 changes: 2 additions & 3 deletions root/etc/s6-overlay/s6-rc.d/svc-spc/run
Original file line number Diff line number Diff line change
@@ -2,6 +2,5 @@

exec \
s6-notifyoncheck -d -n 300 -w 1000 -c "nc -z localhost 8096" \
cd /app/serverpackcreator \
s6-setuidgid abc \
/app/serverpackcreator/java/bin/java -jar /app/serverpackcreator/serverpackcreator.jar -web
cd /app/serverpackcreator s6-setuidgid abc java \
-jar /app/serverpackcreator/serverpackcreator.jar -web
Original file line number Diff line number Diff line change
@@ -86,51 +86,51 @@ class VersionMeta(

@Suppress("MemberVisibilityCanBePrivate")
val legacyFabricUrlGame: URL =
URI("$legacyFabricUrlBase/v2/versions/game").toURL()
URI("$legacyFabricUrlBase/v2/versions/game").toURL() // TODO Move URL to property

@Suppress("MemberVisibilityCanBePrivate")
val legacyFabricUrlLoader: URL =
URI("$legacyFabricUrlBase/v2/versions/loader").toURL()
URI("$legacyFabricUrlBase/v2/versions/loader").toURL() // TODO Move URL to property

@Suppress("MemberVisibilityCanBePrivate")
val legacyfabricUrlManifest: URL =
URI("https://maven.legacyfabric.net/net/legacyfabric/fabric-installer/maven-metadata.xml").toURL()
URI("https://maven.legacyfabric.net/net/legacyfabric/fabric-installer/maven-metadata.xml").toURL() // TODO Move URL to property

@Suppress("MemberVisibilityCanBePrivate")
val minecraftUrlManifest: URL =
URI("https://launchermeta.mojang.com/mc/game/version_manifest.json").toURL()
URI("https://launchermeta.mojang.com/mc/game/version_manifest.json").toURL() // TODO Move URL to property

@Suppress("MemberVisibilityCanBePrivate")
val forgeUrlManifest: URL =
URI("https://files.minecraftforge.net/net/minecraftforge/forge/maven-metadata.json").toURL()
URI("https://files.minecraftforge.net/net/minecraftforge/forge/maven-metadata.json").toURL() // TODO Move URL to property

@Suppress("MemberVisibilityCanBePrivate")
val oldNeoForgeUrlManifest: URL =
URI("https://maven.neoforged.net/releases/net/neoforged/forge/maven-metadata.xml").toURL()
URI("https://maven.neoforged.net/releases/net/neoforged/forge/maven-metadata.xml").toURL() // TODO Move URL to property

@Suppress("MemberVisibilityCanBePrivate")
val newNeoForgeUrlManifest: URL =
URI("https://maven.neoforged.net/releases/net/neoforged/neoforge/maven-metadata.xml").toURL()
URI("https://maven.neoforged.net/releases/net/neoforged/neoforge/maven-metadata.xml").toURL() // TODO Move URL to property

@Suppress("MemberVisibilityCanBePrivate")
val fabricUrlManifest: URL =
URI("https://maven.fabricmc.net/net/fabricmc/fabric-loader/maven-metadata.xml").toURL()
URI("https://maven.fabricmc.net/net/fabricmc/fabric-loader/maven-metadata.xml").toURL() // TODO Move URL to property

@Suppress("MemberVisibilityCanBePrivate")
val fabricUrlIntermediariesManifest: URL =
URI("https://meta.fabricmc.net/v2/versions/intermediary").toURL()
URI("https://meta.fabricmc.net/v2/versions/intermediary").toURL() // TODO Move URL to property

@Suppress("MemberVisibilityCanBePrivate")
val fabricUrlInstallerManifest: URL =
URI("https://maven.fabricmc.net/net/fabricmc/fabric-installer/maven-metadata.xml").toURL()
URI("https://maven.fabricmc.net/net/fabricmc/fabric-installer/maven-metadata.xml").toURL() // TODO Move URL to property

@Suppress("MemberVisibilityCanBePrivate")
val quiltUrlManifest: URL =
URI("https://maven.quiltmc.org/repository/release/org/quiltmc/quilt-loader/maven-metadata.xml").toURL()
URI("https://maven.quiltmc.org/repository/release/org/quiltmc/quilt-loader/maven-metadata.xml").toURL() // TODO Move URL to property

@Suppress("MemberVisibilityCanBePrivate")
val quiltUrlInstallerManifest: URL =
URI("https://maven.quiltmc.org/repository/release/org/quiltmc/quilt-installer/maven-metadata.xml").toURL()
URI("https://maven.quiltmc.org/repository/release/org/quiltmc/quilt-installer/maven-metadata.xml").toURL() // TODO Move URL to property

/**
* The MinecraftMeta instance for working with Minecraft versions and information about them.
@@ -312,8 +312,8 @@ class VersionMeta(
val newContent: String = newManifest.readText()
when (manifestType) {
Type.MINECRAFT -> {
countOldFile = utilities.jsonUtilities.getJson(oldContent).get("versions").size()
countNewFile = utilities.jsonUtilities.getJson(newContent).get("versions").size()
countOldFile = utilities.jsonUtilities.getJson(oldContent).get("versions").size() // TODO Move tagName to property
countNewFile = utilities.jsonUtilities.getJson(newContent).get("versions").size() // TODO Move tagName to property
}

Type.FORGE -> {
@@ -332,9 +332,9 @@ class VersionMeta(

Type.FABRIC, Type.FABRIC_INSTALLER, Type.QUILT, Type.QUILT_INSTALLER, Type.NEO_FORGE -> {
countOldFile = utilities.xmlUtilities.getXml(oldContent)
.getElementsByTagName("version").length
.getElementsByTagName("version").length // TODO Move tagName to property
countNewFile = utilities.xmlUtilities.getXml(newContent)
.getElementsByTagName("version").length
.getElementsByTagName("version").length // TODO Move tagName to property
}

Type.LEGACY_FABRIC -> if (manifestToCheck.name.endsWith(".json")) {
@@ -343,11 +343,11 @@ class VersionMeta(
} else {
val oldXML: Document = utilities.xmlUtilities.getXml(oldContent)
val newXML: Document = utilities.xmlUtilities.getXml(newContent)
countOldFile = oldXML.getElementsByTagName("version").length
countNewFile = newXML.getElementsByTagName("version").length
countOldFile = oldXML.getElementsByTagName("version").length // TODO Move tagName to property
countNewFile = newXML.getElementsByTagName("version").length // TODO Move tagName to property
if (countOldFile == countNewFile) {
if (oldXML.getElementsByTagName("version").item(0).childNodes.item(0)
.nodeValue != newXML.getElementsByTagName("version").item(0).childNodes
if (oldXML.getElementsByTagName("version").item(0).childNodes.item(0) // TODO Move tagName to property
.nodeValue != newXML.getElementsByTagName("version").item(0).childNodes // TODO Move tagName to property
.item(0)
.nodeValue
) {
Original file line number Diff line number Diff line change
@@ -43,13 +43,12 @@ internal class FabricInstaller(
private val utilities: Utilities
) {
@Suppress("MemberVisibilityCanBePrivate")
val installerUrlTemplate =
"https://maven.fabricmc.net/net/fabricmc/fabric-installer/%s/fabric-installer-%s.jar"
val installerUrlTemplate = "https://maven.fabricmc.net/net/fabricmc/fabric-installer/%s/fabric-installer-%s.jar" // TODO Move URL to property
@Suppress("MemberVisibilityCanBePrivate")
val improvedLauncherUrlTemplate = "https://meta.fabricmc.net/v2/versions/loader/%s/%s/%s/server/jar"
private val latest = "latest"
private val release = "release"
private val version = "version"
val improvedLauncherUrlTemplate = "https://meta.fabricmc.net/v2/versions/loader/%s/%s/%s/server/jar" // TODO Move URL to property
private val latest = "latest" // TODO Move tagName to property
private val release = "release" // TODO Move tagName to property
private val version = "version" // TODO Move tagName to property

/**
* Available installer versions for Fabric.
Original file line number Diff line number Diff line change
@@ -44,9 +44,9 @@ internal class FabricLoader(
private set
var release: String? = null
private set
private val latestElement = "latest"
private val releaseElement = "release"
private val version = "version"
private val latestElement = "latest" // TODO Move tagName to property
private val releaseElement = "release" // TODO Move tagName to property
private val version = "version" // TODO Move tagName to property

/**
* Update the Fabric loader versions by parsing the Fabric loader manifest.
Original file line number Diff line number Diff line change
@@ -32,8 +32,8 @@ import java.util.*
* @author Griefed
*/
internal class FabricLoaderDetails(private val objectMapper: ObjectMapper) {
private val urlPrefix = "https://meta.fabricmc.net/v2/versions/loader/"
private val json = "/server/json"
private val urlPrefix = "https://meta.fabricmc.net/v2/versions/loader/" // TODO Move URL to property
private val json = "/server/json" // TODO Move URL to property

/**
* Get the details for a given Minecraft and Fabric version combination.
Original file line number Diff line number Diff line change
@@ -42,7 +42,7 @@ class ForgeInstance(
private val minecraftMeta: MinecraftMeta
) {
val installerUrl: URL =
URI("https://files.minecraftforge.net/maven/net/minecraftforge/forge/$minecraftVersion-$forgeVersion/forge-$minecraftVersion-$forgeVersion-installer.jar").toURL()
URI("https://files.minecraftforge.net/maven/net/minecraftforge/forge/$minecraftVersion-$forgeVersion/forge-$minecraftVersion-$forgeVersion-installer.jar").toURL() // TODO Move URL to property

/**
* Get this Forge instances corresponding Minecraft client instance, wrapped in an
Original file line number Diff line number Diff line change
@@ -45,15 +45,14 @@ class LegacyFabricInstaller(
val allVersions: MutableList<String> = ArrayList(100)

@Suppress("MemberVisibilityCanBePrivate")
val installerUrlTemplate =
"https://maven.legacyfabric.net/net/legacyfabric/fabric-installer/%s/fabric-installer-%s.jar"
val installerUrlTemplate = "https://maven.legacyfabric.net/net/legacyfabric/fabric-installer/%s/fabric-installer-%s.jar" // TODO Move URL to property
var latest: String? = null
private set
var release: String? = null
private set
private val latestElement = "latest"
private val releaseElement = "release"
private val version = "version"
private val latestElement = "latest" // TODO Move tagName to property
private val releaseElement = "release" // TODO Move tagName to property
private val version = "version" // TODO Move tagName to property

/**
* Update all lists of available versions with new information gathered from the manifest.
Original file line number Diff line number Diff line change
@@ -52,8 +52,8 @@ internal abstract class LegacyFabricVersioning(
snapshots.clear()
allVersions.clear()
for (node in utilities.jsonUtilities.getJson(manifest)) {
val version: String = node.get("version").asText()
val stable = node.get("stable").asBoolean()
val version: String = node.get("version").asText() // TODO Move tagName to property
val stable = node.get("stable").asBoolean() // TODO Move tagName to property
allVersions.add(version)
if (stable) {
releases.add(version)
Original file line number Diff line number Diff line change
@@ -54,13 +54,13 @@ internal class MinecraftClientMeta(
private set
var latestSnapshot: MinecraftClient? = null
private set
private val versions = "versions"
private val latestType = "latest"
private val releaseType = "release"
private val snapshotType = "snapshot"
private val type = "type"
private val id = "id"
private val url = "url"
private val versions = "versions" // TODO Move tagName to property
private val latestType = "latest" // TODO Move tagName to property
private val releaseType = "release" // TODO Move tagName to property
private val snapshotType = "snapshot" // TODO Move tagName to property
private val type = "type" // TODO Move tagName to property
private val id = "id" // TODO Move tagName to property
private val url = "url" // TODO Move tagName to property

/**
* Update the meta information.
Original file line number Diff line number Diff line change
@@ -49,11 +49,11 @@ class MinecraftServer internal constructor(
) {
private val manifestFile: File = File(apiProperties.minecraftServerManifestsDirectory, "$minecraftVersion.json")
private var serverJson: JsonNode? = null
private val downloads = "downloads"
private val server = "server"
private val url = "url"
private val javaVersion = "javaVersion"
private val majorVersion = "majorVersion"
private val downloads = "downloads" // TODO Move tagName to property
private val server = "server" // TODO Move tagName to property
private val url = "url" // TODO Move tagName to property
private val javaVersion = "javaVersion" // TODO Move tagName to property
private val majorVersion = "majorVersion" // TODO Move tagName to property

/**
* Get the [URL] to the download of this Minecraft-servers JAR-file.
Original file line number Diff line number Diff line change
@@ -45,7 +45,7 @@ internal class NeoForgeLoader(
private val log by lazy { cachedLoggerOf(this.javaClass) }
val minecraftVersions: MutableList<String> = ArrayList(100)
val neoForgeVersions: MutableList<String> = ArrayList(100)
private val version = "version"
private val version = "version" // TODO Move tagName to property

/**
* 1-n Minecraft version to NeoForge versions.
Original file line number Diff line number Diff line change
@@ -43,7 +43,7 @@ class NewNeoForgeInstance(
) : NeoForgeInstance {

override val installerUrl: URL =
URI("https://maven.neoforged.net/releases/net/neoforged/neoforge/$neoForgeVersion/neoforge-$neoForgeVersion-installer.jar").toURL()
URI("https://maven.neoforged.net/releases/net/neoforged/neoforge/$neoForgeVersion/neoforge-$neoForgeVersion-installer.jar").toURL() // TODO Move URL to property

/**
* Get this Forge instances corresponding Minecraft client instance, wrapped in an
Original file line number Diff line number Diff line change
@@ -42,7 +42,7 @@ class OldNeoForgeInstance(
private val minecraftMeta: MinecraftMeta
) : NeoForgeInstance {
override val installerUrl: URL =
URI("https://maven.neoforged.net/releases/net/neoforged/forge/$minecraftVersion-$neoForgeVersion/forge-$minecraftVersion-$neoForgeVersion-installer.jar").toURL()
URI("https://maven.neoforged.net/releases/net/neoforged/forge/$minecraftVersion-$neoForgeVersion/forge-$minecraftVersion-$neoForgeVersion-installer.jar").toURL() // TODO Move URL to property

/**
* Get this Forge instances corresponding Minecraft client instance, wrapped in an
Original file line number Diff line number Diff line change
@@ -43,7 +43,7 @@ internal class QuiltInstaller(
) {
@Suppress("MemberVisibilityCanBePrivate")
val installerUrlTemplate =
"https://maven.quiltmc.org/repository/release/org/quiltmc/quilt-installer/%s/quilt-installer-%s.jar"
"https://maven.quiltmc.org/repository/release/org/quiltmc/quilt-installer/%s/quilt-installer-%s.jar" // TODO Move URL to property
val installers: MutableList<String> = ArrayList(100)
val installerUrlMeta = HashMap<String, URL>(100)
var latestInstaller: String? = null
@@ -54,9 +54,9 @@ internal class QuiltInstaller(
private set
var releaseInstallerUrl: URL? = null
private set
private val latest = "latest"
private val release = "release"
private val version = "version"
private val latest = "latest" // TODO Move tagName to property
private val release = "release" // TODO Move tagName to property
private val version = "version" // TODO Move tagName to property

/**
* Update the Quilt installer versions by parsing the Fabric loader manifest.
Original file line number Diff line number Diff line change
@@ -44,9 +44,9 @@ internal class QuiltLoader(
private set
var release: String? = null
private set
private val latestElement = "latest"
private val releaseElement = "release"
private val version = "version"
private val latestElement = "latest" // TODO Move tagName to property
private val releaseElement = "release" // TODO Move tagName to property
private val version = "version" // TODO Move tagName to property

/**
* Update the Quilt loader versions by parsing the Fabric loader manifest.
Original file line number Diff line number Diff line change
@@ -34,18 +34,17 @@ import java.io.File
@EntityScan(value = ["de.griefed.serverpackcreator.app"])
@EnableScheduling
class WebService(private val api: ApiWrapper) {
private val log by lazy { cachedLoggerOf(this.javaClass) }

fun start(args: Array<String>): ConfigurableApplicationContext {
val userHome = System.getProperty("user.home")
val lastIndex = "--spring.config.location=classpath:/application.properties," +
"classpath:/serverpackcreator.properties," +
"optional:file:./serverpackcreator.properties," +
"optional:file:./overrides.properties," +
"optional:file:${api.apiProperties.serverPackCreatorPropertiesFile.absolutePath},"+
"optional:file:${api.apiProperties.overridesPropertiesFile.absolutePath}," +
"optional:file:${File(userHome,"serverpackcreator.properties").absolutePath}," +
"optional:file:${File(userHome,"overrides.properties").absolutePath}"
"optional:file:./serverpackcreator.properties," +
"optional:file:${api.apiProperties.overridesPropertiesFile.absolutePath}," +
"optional:file:${File(userHome,"overrides.properties").absolutePath}," +
"optional:file:./overrides.properties"
val springArgs = if (args.isEmpty()) {
arrayOf(lastIndex)
} else {
@@ -71,6 +70,8 @@ class WebService(private val api: ApiWrapper) {
}

companion object {
private val log by lazy { cachedLoggerOf(this.javaClass) }

@Volatile
private var springBootApplicationContext: ConfigurableApplicationContext? = null

@@ -88,6 +89,7 @@ class WebService(private val api: ApiWrapper) {
if (springBootApplicationContext == null) {
synchronized(this) {
if (springBootApplicationContext == null) {
log.debug("Running webservice with ars: $args")
springBootApplicationContext = SpringApplication.run(WebService::class.java, *args)
}
}

0 comments on commit 5caacd0

Please sign in to comment.