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
13 changes: 13 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
FROM openjdk:slim

RUN apt update && apt install -y git

WORKDIR /usr/src/jslt

COPY . .

RUN ./gradlew :playground:shadowJar
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.

I suggest switching to a multi-stage build, so that the final docker container has only the JSLT jar on top of a slimmer JRE image. As it stands the final container will contain the full JDK plus any intermediate build artifacts.

Another alternative would be to build the jar outside docker and then package it in a vanilla JRE image directly. This has the downside that the Dockerfile and a running docker setup are no longer self-sufficient for bootstrapping.

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.

This sounds very reasonable to me.

The number of dependencies is very low. Perhaps we could just get them from Maven Central with wget or something?

+--- project :core
|    \--- com.fasterxml.jackson.core:jackson-databind:2.12.0
|         +--- com.fasterxml.jackson.core:jackson-annotations:2.12.0
|         \--- com.fasterxml.jackson.core:jackson-core:2.12.0
\--- org.eclipse.jetty:jetty-server:9.4.29.v20200521
     +--- javax.servlet:javax.servlet-api:3.1.0
     +--- org.eclipse.jetty:jetty-http:9.4.29.v20200521
     |    +--- org.eclipse.jetty:jetty-util:9.4.29.v20200521
     |    \--- org.eclipse.jetty:jetty-io:9.4.29.v20200521
     |         \--- org.eclipse.jetty:jetty-util:9.4.29.v20200521
     \--- org.eclipse.jetty:jetty-io:9.4.29.v20200521 (*)

We could also host the shadowJar as a github release or something, but this seems maybe simpler and more straightforward?


EXPOSE 9999

CMD ["java", "-cp", "playground/build/libs/playground-0.0.1-all.jar", "no.priv.garshol.jslt.playground.PlaygroundServer", "9999"]
8 changes: 7 additions & 1 deletion playground/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

# JSLT Playground

To build the playground yourself, simply do:
Expand All @@ -15,5 +14,12 @@ To run it, give this command:
java -cp playground/build/libs/playground-0.0.1-all.jar no.priv.garshol.jslt.playground.PlaygroundServer 9999 &
```

or use Docker

```
docker build -t jslt .
docker run -p 9999:9999 jslt
```

Then go to `http://localhost:9999/jslt` and you'll have the playground
right there.
4 changes: 2 additions & 2 deletions playground/src/main/resources/lambda.html
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@
var data = {"json" : input, "jslt" : jslt }

var http = new XMLHttpRequest();
var url = "jslt-demo";
//var url = "http://localhost:9999/jslt";
var url = "jslt";

http.open("POST", url, true);
http.setRequestHeader("Content-type", "application/json");

Expand Down