Last active
April 27, 2022 11:06
-
-
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`
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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