Allow embedded jetty to serve an external resources directory
This commit is contained in:
5
docker/README.md
Normal file
5
docker/README.md
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
To run Pairgoth under docker:
|
||||||
|
|
||||||
|
- compile Pairgoth and copy `application/target/pairgoth-engine.jar` to `docker/data/app`
|
||||||
|
- copy `pairgoth.properties.example` to `docker/data/app/pairgoth.properties` and adapt it to your needs
|
||||||
|
- launch `./run.sh` from within the `docker` directory
|
2
docker/pairgoth.properties.example
Normal file
2
docker/pairgoth.properties.example
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
auth = none
|
||||||
|
|
@@ -119,6 +119,8 @@ abstract class BaseWebappManager(val webappName: String, loggerName: String) : S
|
|||||||
// fail to correctly implement SSL...
|
// fail to correctly implement SSL...
|
||||||
disableSSLCertificateChecks()
|
disableSSLCertificateChecks()
|
||||||
|
|
||||||
|
logger.info("webapp ${webappName} root filesystem path: ${context.getRealPath("")}")
|
||||||
|
|
||||||
} catch (ioe: IOException) {
|
} catch (ioe: IOException) {
|
||||||
logger.error("webapp initialization error", ioe)
|
logger.error("webapp initialization error", ioe)
|
||||||
}
|
}
|
||||||
|
@@ -6,6 +6,7 @@ import org.jeudego.pairgoth.ratings.RatingsManager
|
|||||||
import org.jeudego.pairgoth.util.Translator
|
import org.jeudego.pairgoth.util.Translator
|
||||||
import org.slf4j.LoggerFactory
|
import org.slf4j.LoggerFactory
|
||||||
import java.io.IOException
|
import java.io.IOException
|
||||||
|
import java.nio.file.Paths
|
||||||
import java.security.SecureRandom
|
import java.security.SecureRandom
|
||||||
import java.security.cert.X509Certificate
|
import java.security.cert.X509Certificate
|
||||||
import java.util.*
|
import java.util.*
|
||||||
@@ -14,6 +15,8 @@ import javax.servlet.*
|
|||||||
import javax.servlet.annotation.WebListener
|
import javax.servlet.annotation.WebListener
|
||||||
import javax.servlet.http.HttpSessionEvent
|
import javax.servlet.http.HttpSessionEvent
|
||||||
import javax.servlet.http.HttpSessionListener
|
import javax.servlet.http.HttpSessionListener
|
||||||
|
import kotlin.io.path.createSymbolicLinkPointingTo
|
||||||
|
import kotlin.io.path.exists
|
||||||
|
|
||||||
@WebListener
|
@WebListener
|
||||||
class WebappManager : BaseWebappManager("View Webapp", "view") {
|
class WebappManager : BaseWebappManager("View Webapp", "view") {
|
||||||
@@ -22,6 +25,17 @@ class WebappManager : BaseWebappManager("View Webapp", "view") {
|
|||||||
override fun contextInitialized(sce: ServletContextEvent) {
|
override fun contextInitialized(sce: ServletContextEvent) {
|
||||||
super.contextInitialized(sce)
|
super.contextInitialized(sce)
|
||||||
|
|
||||||
|
// create a symlink for external resources access
|
||||||
|
properties.getProperty("cwd")?.let { cwd ->
|
||||||
|
val target = Paths.get(cwd).resolve("resources")
|
||||||
|
if (target.exists()) {
|
||||||
|
val source = Paths.get(context.getRealPath("/")).resolve("resources")
|
||||||
|
if (!source.exists()) {
|
||||||
|
source.createSymbolicLinkPointingTo(target)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// publish some properties to the webapp context; for easy access from the template
|
// publish some properties to the webapp context; for easy access from the template
|
||||||
context.setAttribute("env", properties.getProperty("env") ?: "dev")
|
context.setAttribute("env", properties.getProperty("env") ?: "dev")
|
||||||
context.setAttribute("version", properties.getProperty("version") ?: "?")
|
context.setAttribute("version", properties.getProperty("version") ?: "?")
|
||||||
|
@@ -23,6 +23,7 @@ import java.net.URLDecoder
|
|||||||
import java.nio.charset.StandardCharsets
|
import java.nio.charset.StandardCharsets
|
||||||
import java.nio.file.Files
|
import java.nio.file.Files
|
||||||
import java.nio.file.Path
|
import java.nio.file.Path
|
||||||
|
import java.nio.file.Paths
|
||||||
import java.security.KeyFactory
|
import java.security.KeyFactory
|
||||||
import java.security.KeyStore
|
import java.security.KeyStore
|
||||||
import java.security.cert.CertificateFactory
|
import java.security.cert.CertificateFactory
|
||||||
@@ -109,10 +110,11 @@ private fun publishProperties() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// we want colorized output on linux
|
// we want colorized output on linux
|
||||||
if (System.getProperty("os.name") == "Linux")
|
if (System.getProperty("os.name") == "Linux") {
|
||||||
{
|
|
||||||
System.setProperty("org.eclipse.jetty.logging.appender.MESSAGE_ESCAPE", "false");
|
System.setProperty("org.eclipse.jetty.logging.appender.MESSAGE_ESCAPE", "false");
|
||||||
}
|
}
|
||||||
|
// remember the current working directory
|
||||||
|
System.setProperty("pairgoth.cwd", Paths.get("").toAbsolutePath().toString())
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun extractWarFiles() {
|
private fun extractWarFiles() {
|
||||||
@@ -219,6 +221,8 @@ private fun createContext(webapp: String, contextPath: String) = WebAppContext()
|
|||||||
context.contextPath = contextPath
|
context.contextPath = contextPath
|
||||||
if (webapp == "api") {
|
if (webapp == "api") {
|
||||||
context.allowNullPathInfo = true
|
context.allowNullPathInfo = true
|
||||||
|
} else {
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user