| borgbutler-docker/app/Dockerfile | ●●●●● patch | view | raw | blame | history | |
| borgbutler-docker/app/entrypoint.sh | ●●●●● patch | view | raw | blame | history | |
| borgbutler-server/build.gradle | ●●●●● patch | view | raw | blame | history | |
| borgbutler-server/src/main/kotlin/de/micromata/borgbutler/server/BorgButlerApplication.kt | ●●●●● patch | view | raw | blame | history | |
| borgbutler-server/src/main/kotlin/de/micromata/borgbutler/server/RunningMode.kt | ●●●●● patch | view | raw | blame | history | |
| borgbutler-server/src/main/kotlin/de/micromata/borgbutler/server/WebConfig.kt | ●●●●● patch | view | raw | blame | history | |
| borgbutler-server/src/main/kotlin/de/micromata/borgbutler/server/WebController.kt | ●●●●● patch | view | raw | blame | history | |
| borgbutler-webapp/build.gradle | ●●●●● patch | view | raw | blame | history |
borgbutler-docker/app/Dockerfile
@@ -27,11 +27,6 @@ #COPY shutdown.sh /app #COPY startup.sh /app #ARG JAVA_OPTS="-Xms1g -Xmx1g" #ENV JAVA_OPTS_VAR=$JAVA_OPTS # -Dloader.path=${HOME}/ProjectForge/resources/milton ${DEBUGOPTS} # Variable expansion doesn't work for ENTRYPOINT definition as array, but array is required, because graceful shutdown of # container isn't given if java is started via 'sh -c' as it will be done by ENTRYPOINT java ..... # Java options are modifiable by user through own ENTRYPOINT definition on docker run or in docker-compose.yml. borgbutler-docker/app/entrypoint.sh
@@ -49,7 +49,7 @@ echo "Starting java ${JAVA_OPTS} -cp app/web/*:app/lib/* -DBorgButlerHome=/BorgButler/ -DapplicationHome=/app -DbindAddress=0.0.0.0 -DallowedClientIps=172.17. ${JAVA_MAIN} -q ${JAVA_ARGS}" java $JAVA_OPTS -cp app/web/*:app/lib/* -DborgbutlerHome=/BorgButler/ -DapplicationHome=/app -DbindAddress=0.0.0.0 -DallowedClientIps=172.17. $JAVA_MAIN -q $JAVA_ARGS & java $JAVA_OPTS -cp app/web/*:app/lib/* -DborgbutlerHome=/BorgButler/ -DapplicationHome=/app -Dserver.address=0.0.0.0 -DallowedClientIps=172.17. $JAVA_MAIN -q $JAVA_ARGS & CHILD=$! wait $CHILD borgbutler-server/build.gradle
@@ -6,6 +6,7 @@ dependencies { compile project(':borgbutler-core') compile project(':borgbutler-webapp') // https://mvnrepository.com/artifact/org.apache.commons/commons-text implementation group: 'org.apache.commons', name: 'commons-text', version: '1.6' implementation group: 'org.apache.commons', name: 'commons-collections4', version: '4.2' @@ -64,18 +65,6 @@ dependsOn createVersionProperties } // Builds the distribution distributions { main { contents { // Prepared by nbmBuild: from ("${project(':borgbutler-webapp').projectDir}/build") { into 'web' } } } } distZip.dependsOn ':borgbutler-webapp:npmBuild' distZip.dependsOn ':borgbutler-webapp:packageWebApp' //distZip.dependsOn ':borgbutler-docs:buildWebDoc' task(dist).dependsOn distZip borgbutler-server/src/main/kotlin/de/micromata/borgbutler/server/BorgButlerApplication.kt
@@ -46,7 +46,8 @@ // Preread configuration to get setting development mode for WebConfig (logging not yet initialized, so // reread configuration later after logging is available for getting log information on errors etc.) val configuration = ConfigurationHandler.readJsonConfigfile(File(borgButlerHome)) RunningMode.webDevelopment = RunningMode.runningInIDE || (configuration as? ServerConfiguration)?.webDevelopmentMode == true RunningMode.webDevelopment = RunningMode.runningInIDE || (configuration as? ServerConfiguration)?.webDevelopmentMode == true if (System.getProperty("LOG_PATH").isNullOrBlank()) { // Needed by logback-spring.xml System.setProperty("LOG_PATH", borgButlerHome) @@ -103,7 +104,11 @@ BorgInstallation.getInstance().initialize() // 0.0.0.0 for Docker installations. val url = "http://$serverAddress:$serverPort/".replace("0.0.0.0", "127.0.0.1") var url = "http://$serverAddress:$serverPort/" if (serverAddress.contains("0.0.0.0")) { log.info { "Server bind address: $url" } url = url.replace("0.0.0.0", "127.0.0.1") } val uri = URI.create(url) val quietMode = line.hasOption('q') if (!quietMode && RunningMode.desktopSupportsBrowse && RunningMode.headlessMode) { @@ -132,6 +137,7 @@ @EventListener(ApplicationReadyEvent::class) open fun startApp() { log.info { "Start-up of BorgButler finished. Have fun!" } } @PreDestroy borgbutler-server/src/main/kotlin/de/micromata/borgbutler/server/RunningMode.kt
@@ -2,7 +2,6 @@ import org.slf4j.LoggerFactory import java.awt.Desktop import java.io.File import java.util.* object RunningMode { @@ -41,13 +40,12 @@ val runningInIDE: Boolean get() { val currentDir = System.getProperty("user.dir") val coreDir = File(currentDir, "borgbutler-core") val development = coreDir.exists() && File(coreDir, "build.gradle").exists() if (development) { log.warn("*** Starting BorgButler server in IDE mode. This mode shouldn't be used in production environments. ***") if (webBundled()) { return true } else { log.warn("*** BorgButler seems to run inside an IDE. ***") return false } return development } /** @@ -62,6 +60,19 @@ ) } fun webBundled(): Boolean { var available = false RunningMode::class.java.getResourceAsStream("/web/index.html")?.use { //RunningMode::class.java.getResourceAsStream("/logback-spring.xml")?.use { log.info("Web app found (is bundled).") available = true } if (!available) { log.info("Web app isn't bundled (running in IDE?)") } return available } enum class UserManagement { SINGLE } borgbutler-server/src/main/kotlin/de/micromata/borgbutler/server/WebConfig.kt
@@ -1,10 +1,13 @@ package de.micromata.borgbutler.server import mu.KotlinLogging import org.springframework.context.annotation.Bean import org.springframework.context.annotation.Configuration import org.springframework.web.servlet.ViewResolver import org.springframework.web.servlet.config.annotation.CorsRegistry import org.springframework.web.servlet.config.annotation.EnableWebMvc import org.springframework.web.servlet.config.annotation.WebMvcConfigurer import org.springframework.web.servlet.view.InternalResourceViewResolver private val log = KotlinLogging.logger {} @@ -12,6 +15,18 @@ @Configuration @EnableWebMvc open class WebConfig : WebMvcConfigurer { @Bean open fun internalResourceViewResolver(): ViewResolver { val bean = InternalResourceViewResolver() if (RunningMode.webBundled()) { bean.setPrefix("/web/") } else { bean.setPrefix("borgbutler-webapp/build/") } bean.setSuffix(".html") return bean } override fun addCorsMappings(registry: CorsRegistry) { if (RunningMode.webDevelopment) { log.warn("*********************************") borgbutler-server/src/main/kotlin/de/micromata/borgbutler/server/WebController.kt
New file @@ -0,0 +1,15 @@ package de.micromata.borgbutler.server import mu.KotlinLogging import org.springframework.stereotype.Controller import org.springframework.web.bind.annotation.RequestMapping private val log = KotlinLogging.logger {} @Controller open class WebConntroller { @RequestMapping("/") fun index(): String { return "index" } } borgbutler-webapp/build.gradle
@@ -2,7 +2,24 @@ task npmBuild(type: Exec) { workingDir '.' executable 'sh' commandLine 'npm', 'run', 'build' } task packageWebApp(type: Zip) { dependsOn npmBuild baseName 'borgbutler-webapp' extension 'jar' destinationDir file("${projectDir}") from('build') { // optional path under which output will be visible in Java classpath, e.g. static resources path into 'webapp' } doLast { //println "**** projectDir=${projectDir}, buildDir=${buildDir}" mkdir "${buildDir}/libs" def jarFile = archiveFileName.get() ant.move file: "${projectDir}/${jarFile}", toDir: "${buildDir}/libs" } }