Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file not shown.
30 changes: 0 additions & 30 deletions elda-assets/src/main/webapp/WEB-INF/urlrewrite.xml

This file was deleted.

15 changes: 0 additions & 15 deletions elda-assets/src/main/webapp/WEB-INF/web.xml

This file was deleted.

12 changes: 0 additions & 12 deletions elda-assets/src/main/webapp/logback.xml

This file was deleted.

10 changes: 10 additions & 0 deletions elda-standalone/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
FROM amazoncorretto:21-alpine3.20

ENV ELDA_PORT=8080
EXPOSE 8080

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe also a good idea to set a default elda_webapp_path and document that, as the internally set default is not really appropriate in the Docker environment.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.


ENV ELDA_WEBAPP_PATH=/etc/elda

COPY target/elda-standalone-jar-with-dependencies.jar app.jar

CMD java -jar /app.jar
35 changes: 25 additions & 10 deletions elda-standalone/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<version>3.0.1-SNAPSHOT</version>
</parent>
<artifactId>elda-standalone</artifactId>
<packaging>war</packaging>
<packaging>jar</packaging>
<name>elda-standalone</name>
<description>instant Elda webapp</description>

Expand All @@ -18,21 +18,12 @@
<groupId>org.apache.tomcat.embed</groupId>
<artifactId>tomcat-embed-core</artifactId>
<version>${tomcat.version}</version>
<scope>provided</scope>
</dependency>

<dependency>
<groupId>org.apache.tomcat.embed</groupId>
<artifactId>tomcat-embed-jasper</artifactId>
<version>${tomcat.version}</version>
<scope>provided</scope>
</dependency>

<dependency>
<groupId>com.epimorphics.lda</groupId>
<artifactId>elda-assets</artifactId>
<version>${project.version}</version>
<type>war</type>
</dependency>

<dependency>
Expand All @@ -57,6 +48,30 @@
<build>
<finalName>elda-standalone</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<version>3.8.0</version>
<configuration>
<archive>
<manifest>
<mainClass>run.standalone</mainClass>
</manifest>
</archive>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
<executions>
<execution>
<id>make-assembly</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
Expand Down
48 changes: 48 additions & 0 deletions elda-standalone/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# ELDA Standalone Application

This module contains a standalone ELDA application which runs an embedded Tomcat server.

To build:
* `mvn clean package`

To run:
* `java -jar target/elda-standalone-jar-with-dependencies.jar`

### Sample Web Server

By default, the application loads a web server configuration, including ELDA API specs,
from the `src/main/webapp` directory, which contains a small sample API.
When running with the sample API, check http://localhost:8080/standalone/again/games.ttl to confirm that the
server is running correctly.

Note that the sample API does not support HTML rendering.

### Configuring the Web Server

To run the application with your own web server configuration,
set the `ELDA_WEBAPP_PATH` environment variable to the path to your web app directory.
This directory **must contain** a `web.xml` file which configures the web server.

It must also contain the ELDA API specs and static resources (velocity templates, scripts, stylesheets etc.)
you want to serve.

To run the web server with a context path, set the `ELDA_CONTEXT_PATH` environment variable to the context path.
The default context path is `/standalone`.
To run without a context path set the environment variable to `/`.

To run the web server with an alternate port (the default is 8080), set the `ELDA_PORT` environment variable to the port number.
Comment on lines +22 to +33

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor stylistic point but a table of configuration variables with meaning and default is easier to read and check off against than a block of prose.


### Docker Image

To build the standalone application as a Docker image, run:
* `docker build -t elda/standalone:test .`

The image does not contain any web server configuration or ELDA API specs,
hence these must be mounted to a running container as a volume.
The default web app directory is `/etc/elda`.

To run the image in a Docker container, run:
* `docker run -p 8080:8080 -v {host webapp dir}:{container webapp dir} -e ELDA_WEBAPP_PATH={container webapp dir} elda/standalone:test`

For example, to run with the sample web server:
* `docker run -p 8080:8080 -v ./src/main/webapp:/etc/elda -e ELDA_WEBAPP_PATH=/etc/elda elda/standalone:test`
36 changes: 18 additions & 18 deletions elda-standalone/src/main/java/run/standalone.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,31 +12,31 @@

import org.apache.catalina.connector.Connector;
import org.apache.catalina.startup.Tomcat;
import org.apache.jena.riot.RIOT;

public class standalone {

static final String standalone = "/standalone";
static final String ROOT = "/";
public class standalone {

public static void main( String [] args ) throws Exception {
Tomcat server = new Tomcat();
int port = 8080;
String portString = System.getProperty("elda.port");
if (portString != null) port = Integer.parseInt(portString);
public static void main( String [] args ) throws Exception {
RIOT.init();
Tomcat server = new Tomcat();
String portString = System.getProperty ("ELDA_PORT");
int port = portString != null ? Integer.parseInt(portString) : 8080;

String ctxPath = System.getenv("ELDA_CONTEXT_PATH");
ctxPath = ctxPath != null ? ctxPath : "/standalone";

String basePath = System.getenv("ELDA_WEBAPP_PATH");
basePath = basePath != null ? basePath : "src/main/webapp";

Connector connector = new Connector();
connector.setPort(port);
server.getService().addConnector(connector);

server.setBaseDir(".");

// System.err.println(">> " + new File(".").getAbsolutePath());
// String absolutePath = new File("target/elda-standalone").getAbsolutePath();
String absolutePath = new File("src/main/webapp").getAbsolutePath();
// System.err.println(">> " + absolutePath);
server.addWebapp(standalone, absolutePath);
server.addWebapp(ROOT, absolutePath);
//

String absolutePath = new File(basePath).getAbsolutePath();
server.addWebapp(ctxPath, absolutePath);

server.getConnector();
server.start();
server.getServer().await();
}
Expand Down
21 changes: 7 additions & 14 deletions elda-standalone/src/main/webapp/WEB-INF/web.xml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
<filter-class>org.glassfish.jersey.servlet.ServletContainer</filter-class>

<init-param>
<param-name>jersey.config.property.packages</param-name>
<param-name>jersey.config.server.provider.packages</param-name>
<param-value>com.epimorphics.lda.restlets</param-value>
</init-param>

Expand All @@ -53,25 +53,18 @@
<param-name>jersey.spi.container.ContainerRequestFilters</param-name>
<param-value>org.glassfish.jersey.api.container.filter.PostReplaceFilter</param-value>
</init-param>

<init-param>
<param-name>jersey.config.servlet.filter.staticContentRegex</param-name>
<param-value>/velocity/.+</param-value>
</init-param>
</filter>

<!-- ==================================================================== -->

<filter-mapping>
<filter-name>Jersey Web Application</filter-name>
<url-pattern>/api-config/*</url-pattern>
<url-pattern>/control/*</url-pattern>
<url-pattern>/hello/*</url-pattern>
<url-pattern>/again/*</url-pattern>
<url-pattern>/tiny/*</url-pattern>
<url-pattern>/mini/*</url-pattern>
<url-pattern>/full/*</url-pattern>
<url-pattern>/velocity/*</url-pattern>
<url-pattern>/velocity-dev/*</url-pattern>
<url-pattern>/ved/*</url-pattern>
<url-pattern>/bwq/*</url-pattern>
<url-pattern>/api-config/*</url-pattern>
<url-pattern>/control/*</url-pattern>
<url-pattern>/*</url-pattern>
</filter-mapping>

<servlet-mapping>
Expand Down
Loading