Skip to content

Instantly share code, notes, and snippets.

@maxandersen
Last active April 27, 2022 11:06
Show Gist options
  • Save maxandersen/f077f1d356c42eeb395a8811d6152f3a to your computer and use it in GitHub Desktop.
Save maxandersen/f077f1d356c42eeb395a8811d6152f3a to your computer and use it in GitHub Desktop.
This is a standalone dockerfile with embedded java and using jbang for building as answer to https://twitter.com/jordisola_/status/1517244462673674240?s=20 Try out using: `docker build -t myapp . && docker run -p 8080:8080 myapp`
# syntax=docker/dockerfile:1.4
FROM jbangdev/jbang-action as builder
WORKDIR /
COPY <<EOF main.java
//DEPS io.quarkus:quarkus-bom:2.8.0.Final@pom
//DEPS io.quarkus:quarkus-resteasy-reactive
import javax.ws.rs.*;
import javax.ws.rs.core.MediaType;
@Path("/")
public class main {
@GET
@Produces(MediaType.TEXT_PLAIN)
public String hello() {
return "hello\\n";
}
}
EOF
RUN chmod +x main.java && mkdir output
RUN jbang export portable -O output/app.jar main.java
FROM eclipse-temurin:17
COPY --from=builder /output /output
CMD ["java", "-jar", "output/app.jar"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment