diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..df3d0f1 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,17 @@ + +# IDE +.idea/ +.vscode/ +.gradle/ +.settings/ +/src/test/java/test/* +/src/test/resources/test/* + +#build +/build/ +/bin/ +.project +lcoal.properties + +# debug dir +/run/ diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..055ebfc --- /dev/null +++ b/Dockerfile @@ -0,0 +1,21 @@ +FROM eclipse-temurin:20-jdk as build +LABEL authors="A.C.Sukazyo Eyre" + +COPY . /app/source/ +WORKDIR /app + +RUN cd ./source \ +&& ./gradlew shadowJar -PdockerBuild \ +&& cd .. \ +&& cp ./source/build/libs/morny-coeur-docker-build.jar ./morny-coeur.jar +#&& rm -r ./source \ +#&& rm -r /root/.gradle \ + + +FROM eclipse-temurin:20-jre + +COPY --from=build /app/morny-coeur.jar /app/morny-coeur.jar +WORKDIR /app + +ENTRYPOINT ["java", "-jar", "morny-coeur.jar"] +CMD ["-q", "-v"] diff --git a/build.gradle b/build.gradle index 7c34aa5..6ec4e7d 100644 --- a/build.gradle +++ b/build.gradle @@ -1,36 +1,36 @@ -import org.ajoberstar.grgit.Status - -import java.nio.charset.Charset -import java.nio.charset.StandardCharsets - plugins { id 'java' id 'java-library' id 'application' id 'maven-publish' - id 'com.github.johnrengelman.shadow' version '7.1.2' + id 'com.github.johnrengelman.shadow' version '8.1.1' id 'com.github.gmazzo.buildconfig' version '3.1.0' - id 'org.ajoberstar.grgit' version '5.0.0' + id 'org.ajoberstar.grgit' version '5.2.0' } +import org.ajoberstar.grgit.Status + +import java.nio.charset.Charset +import java.nio.charset.StandardCharsets + final boolean proj_git = grgit!=null final String proj_store = MORNY_CODE_STORE final String proj_commit = proj_git ? grgit.head().id : null final String proj_commit_path = MORNY_COMMIT_PATH final boolean proj_clean = isCleanBuild() if (!proj_git) - print "[MornyBuild] git repository not available for current working space! git version tag will be disabled." + println "[MornyBuild] git repository not available for current working space! git version tag will be disabled." else if (isCleanBuild()) { - print "git: clean build at ${grgit.head().id}" + println "git: clean build at ${grgit.head().id}" } else { final Status status = grgit.status() - print "git: non-clean-build" + println "git: non-clean-build" if (!status.unstaged.allChanges.empty) { - print "\ngit: unstaged changes" + println "git: unstaged changes" listChanges(status.unstaged) } if (!status.staged.allChanges.empty) { - print "\ngit: staged changes" + println "git: staged changes" listChanges(status.staged) } } @@ -134,7 +134,15 @@ buildConfig { } shadowJar { + archiveClassifier.set "fat" + + if (project.hasProperty("dockerBuild")) { + println "shadow-jar: using docker build name" + archiveVersion.set "" + archiveClassifier.set "docker-build" + } + } @SuppressWarnings("all") @@ -151,11 +159,11 @@ boolean isCleanBuild () { void listChanges (Status.Changes listing) { for (String file in listing.added) - print "\n add: ${file}" + println " add: ${file}" for (String file in listing.modified) - print "\n mod: ${file}" + println " mod: ${file}" for (String file in listing.removed) - print "\n del: ${file}" + println " del: ${file}" } publishing { diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..4d8cce6 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,4 @@ +services: + coeur-app: + build: . + command: -v diff --git a/gradle.properties b/gradle.properties index 710c744..9946e84 100644 --- a/gradle.properties +++ b/gradle.properties @@ -5,7 +5,7 @@ MORNY_ARCHIVE_NAME = morny-coeur MORNY_CODE_STORE = https://github.com/Eyre-S/Coeur-Morny-Cono MORNY_COMMIT_PATH = https://github.com/Eyre-S/Coeur-Morny-Cono/commit/%s -VERSION = 1.0.0-RC3.7 +VERSION = 1.0.0-RC3.8 USE_DELTA = false VERSION_DELTA = diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index ae04661..84a0b92 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.5.1-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.2.1-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/src/main/java/cc/sukazyo/cono/morny/ServerMain.java b/src/main/java/cc/sukazyo/cono/morny/ServerMain.java index 87d988e..9a0e931 100644 --- a/src/main/java/cc/sukazyo/cono/morny/ServerMain.java +++ b/src/main/java/cc/sukazyo/cono/morny/ServerMain.java @@ -97,6 +97,7 @@ public class ServerMain { List unknownArgs = new ArrayList<>(); + //# 从命令行参数设置启动参数 for (int i = 0; i < args.length; i++) { if (args[i].startsWith("-")) { @@ -200,6 +201,17 @@ public class ServerMain { } + //# 从环境变量设置启动参数 + String propToken = null; + String propTokenKey = null; + for (String iKey : MornyConfig.PROP_TOKEN_KEY) { + if (System.getenv(iKey) != null) { + propToken = System.getenv(iKey); + propTokenKey = iKey; + } + } + + //# //# 启动信息输出 //# 启动相关参数的检查和处理 @@ -215,15 +227,6 @@ public class ServerMain { logger.debug("Debug log output enabled."); - String propToken = null; - String propTokenKey = null; - for (String iKey : MornyConfig.PROP_TOKEN_KEY) { - if (System.getenv(iKey) != null) { - propToken = System.getenv(iKey); - propTokenKey = iKey; - } - } - if (versionEchoMode) { logger.info(String.format("""