Skip to content

Instantly share code, notes, and snippets.

@torrespro
Created December 28, 2021 12:50
Show Gist options
  • Save torrespro/2e2dfcc21726cd3cdb203f5a9b27e019 to your computer and use it in GitHub Desktop.
Save torrespro/2e2dfcc21726cd3cdb203f5a9b27e019 to your computer and use it in GitHub Desktop.
A #docker container that runs #Java webserver ('jwebserver' command line tool in #jdk18) to serve javadoc. Note the use of #jlink tool to create minimal JRE with just the jdk.httpserver module + its transitive dependencies. Credit to: https://twitter.com/sundararajan_a/status/1473465961818701824
FROM openjdk:18-jdk-oraclelinux8 as build
#minimum jre image for webserver
RUN jlink --add-modules jdk.httpserver --output java_http
RUN curl \
https://download.oracle.com/otn_software/java/jdk/17.0.1+12/2a2082e5a09d4267845be086888add4f/jdk-17.0.1_doc-all.zip \
--output docs.zip && \
jar xvf docs.zip
FROM oraclelinux:8-slim
#copy minimal jre and docs directory
COPY --from=build java_http java_http
COPY --from=build docs docs
EXPOSE 8000
#start webserver to serve javadoc from /docs
ENTRYPOINT ["/java_http/bin/jwebserver", "-b", "0.0.0.0", "-d", "/docs"]
@rajeshhazari
Copy link

rajeshhazari commented Aug 7, 2023

Thanks for sharing thi.
Is oracleLinuxv8 is not jfk 8 right, need to verify after I download?
While you are creating this wouldn't this be helpful to add some non root user, can you please share and how do we start https using openssl cert?
Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment