Skip to content

Commit

Permalink
migrate to boot jar
Browse files Browse the repository at this point in the history
  • Loading branch information
yuzawa-san committed Aug 1, 2023
1 parent 32e19c4 commit caeb0a7
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 49 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
bundler-cache: true
- name: Build with Gradle
run: |
./gradlew --no-daemon -s build buildDeb installDist
./gradlew --no-daemon -s build buildDeb installBootDist
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
Expand Down Expand Up @@ -64,7 +64,7 @@ jobs:
prerelease: false
- name: Get the ZIP
id: get_zip
run: echo ::set-output name=filename::$(basename $(find build/distributions -name "*.zip"))
run: echo ::set-output name=filename::$(basename $(find build/distributions -name "*-boot-*.zip"))
- name: Upload Release ZIP
id: upload-release-asset-zip
uses: actions/upload-release-asset@v1
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
FROM eclipse-temurin:17-jre-focal
WORKDIR /opt/googolplex-theater
COPY build/install/googolplex-theater/ .
COPY build/install/googolplex-theater-boot/ .
EXPOSE 8000
EXPOSE 5353/udp
VOLUME ["/opt/googolplex-theater/conf"]
Expand Down
36 changes: 6 additions & 30 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -114,63 +114,39 @@ test {
finalizedBy jacocoTestReport
}

def getGitHash = { ->
def stdout = new ByteArrayOutputStream()
exec {
commandLine 'git', 'rev-parse', 'HEAD'
standardOutput = stdout
}
return stdout.toString().trim()
}

application {
mainClass = 'com.jyuzawa.googolplex_theater.GoogolplexTheater'
}

jar {
doFirst {
manifest {
attributes(
'Built-By' : System.properties['user.name'],
'Build-Timestamp' : new java.text.SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ").format(new Date()),
'Implementation-Version' : project.version,
'Implementation-Title' : project.name,
'Specification-Version' : "${-> getGitHash()}",
'Created-By' : "Gradle ${gradle.gradleVersion}",
'Build-Jdk' : "${System.properties['java.version']} (${System.properties['java.vendor']} ${System.properties['java.vm.version']})",
'Build-OS' : "${System.properties['os.name']} ${System.properties['os.arch']} ${System.properties['os.version']}"
)
}
}
}
jar.dependsOn(generateLicenseReport)
bootJar.dependsOn(generateLicenseReport)

distributions {
main {
boot {
contents {
from 'LICENSE'
from 'README.md'
from "${project.buildDir}/reports/dependency-license/THIRD-PARTY-NOTICES.txt"
from "${projectDir}/src/dist"
}
}
}

buildDeb {
release '1'
dependsOn installDist
dependsOn installBootDist
license "MIT"
url "https://github.com/yuzawa-san/googolplex-theater"
packager "James Yuzawa"
into '/opt/googolplex-theater'
user 'googolplex-theater'
permissionGroup 'googolplex-theater'
requires("default-jre-headless")
from("${project.buildDir}/install/googolplex-theater") {
from("${project.buildDir}/install/googolplex-theater-boot") {
exclude 'conf'
exclude 'service'
fileMode 0755
}
from("${project.buildDir}/install/googolplex-theater/conf") {
from("${project.buildDir}/install/googolplex-theater-boot/conf") {
fileType CONFIG | NOREPLACE
fileMode 0644
into 'conf'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,6 @@ public class GoogolplexService implements Closeable {

static {
log.info("Website: " + PROJECT_WEBSITE);
Package thePackage = GoogolplexTheater.class.getPackage();
log.info("Revision: {}", thePackage.getSpecificationVersion());
for (String property : DIAGNOSTIC_PROPERTIES) {
log.info("Runtime[{}]: {}", property, System.getProperty(property));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.system.ApplicationHome;
import org.springframework.context.annotation.Bean;

/**
Expand All @@ -27,20 +28,12 @@ public Path appHome(@Value("${googolplex-theater.app-home}") Path appHome) {

public static void main(String[] args) throws Exception {
Path appHome = Paths.get("src/dist").toAbsolutePath();
try {
Path jarPath = Paths.get(GoogolplexTheater.class
.getProtectionDomain()
.getCodeSource()
.getLocation()
.toURI());
if (Files.isRegularFile(jarPath)) {
appHome = jarPath.resolve("../../").normalize().toAbsolutePath();
System.setProperty(
"spring.config.import",
appHome.resolve("./conf/config.yml").toString());
}
} catch (Exception e) {
// pass
ApplicationHome home = new ApplicationHome(GoogolplexTheater.class);
Path jarPath = home.getSource().toPath();
if (Files.isRegularFile(jarPath)) {
appHome = jarPath.resolve("../../").normalize().toAbsolutePath();
System.setProperty(
"spring.config.import", appHome.resolve("conf/config.yml").toString());
}
System.setProperty("googolplex-theater.app-home", appHome.toString());
SpringApplication.run(GoogolplexTheater.class, args);
Expand Down

0 comments on commit caeb0a7

Please sign in to comment.