jte icon indicating copy to clipboard operation
jte copied to clipboard

Support for read-only filesystem

Open mibutec opened this issue 1 year ago • 1 comments

Just trying to run an application using jte in our Kubernetes Cluster. As we have to use read-only filesystem in our containers I get

...
Caused by: java.io.UncheckedIOException: java.nio.file.FileSystemException: /jte-classes: Read-only file system
	at gg.jte.compiler.TemplateCompiler.generate(TemplateCompiler.java:186)
	at gg.jte.compiler.TemplateCompiler.precompile(TemplateCompiler.java:93)
	at gg.jte.compiler.TemplateCompiler.load(TemplateCompiler.java:50)
	at gg.jte.TemplateEngine.lambda$resolveTemplateOnDemand$0(TemplateEngine.java:354)
	at java.base/java.util.concurrent.ConcurrentHashMap.compute(ConcurrentHashMap.java:1916)
	at gg.jte.TemplateEngine.resolveTemplateOnDemand(TemplateEngine.java:347)
	at gg.jte.TemplateEngine.resolveTemplate(TemplateEngine.java:337)
	at gg.jte.TemplateEngine.render(TemplateEngine.java:210)
	at mainapp.templating.JteRenderer.renderHtml(JteRenderer.java:37)
	at mainapp.TestExecutionController.getUI(TestExecutionController.java:117)
	at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103)
	... 13 more
Caused by: java.nio.file.FileSystemException: /jte-classes: Read-only file system
	at java.base/sun.nio.fs.UnixException.translateToIOException(UnixException.java:100)
	at java.base/sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:106)
	at java.base/sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:111)
	at java.base/sun.nio.fs.UnixFileSystemProvider.createDirectory(UnixFileSystemProvider.java:438)
	at java.base/java.nio.file.Files.createDirectory(Files.java:699)
	at java.base/java.nio.file.Files.createAndCheckIsDirectory(Files.java:807)
	at java.base/java.nio.file.Files.createDirectories(Files.java:793)
	at gg.jte.output.FileOutput.<init>(FileOutput.java:21)
	at gg.jte.output.FileOutput.<init>(FileOutput.java:17)
	at gg.jte.compiler.TemplateCompiler.generate(TemplateCompiler.java:183)
	... 23 more

I get around this when mounting an emptyDir into this locations, but it would be nice to get around this hack. Is it possible to run jte without writing into file-system?

mibutec avatar Mar 27 '24 08:03 mibutec

Hi @mibutec,

the ideal solution for this would be to precompile jte templates in your build process.

This way they can be deployed to the readonly Kubernetes filesystem like regular compiled Java classes.

This would be a good starting point: https://jte.gg/pre-compiling/

casid avatar Mar 27 '24 10:03 casid