Skip to content

Instantly share code, notes, and snippets.

@reitzig
Created May 20, 2020 08:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save reitzig/fbd5bb9e02a4b1fc9eeffa7544d25732 to your computer and use it in GitHub Desktop.
Save reitzig/fbd5bb9e02a4b1fc9eeffa7544d25732 to your computer and use it in GitHub Desktop.
UBI Minimial with Kotlin Native
FROM registry.access.redhat.com/ubi7/ubi:latest AS build
RUN yum -y install --disableplugin=subscription-manager \
java-11-openjdk
ARG kotlin_version=1.3.72
RUN curl -LO https://github.com/JetBrains/kotlin/releases/download/v${kotlin_version}/kotlin-native-linux-${kotlin_version}.tar.gz \
&& tar -xzf kotlin-native-linux-${kotlin_version}.tar.gz \
&& rm kotlin-native-linux-${kotlin_version}.tar.gz
# Run compiler once so it downloads native dependencies into a separate layer
RUN export PATH=kotlin-native-linux-${kotlin_version}/bin:$PATH \
&& echo "fun main() { println(\"Foo!\") }" > foo.kt \
&& kotlinc-native foo.kt -o foo \
&& rm foo*
COPY hello-world.kt ./
RUN export PATH=kotlin-native-linux-${kotlin_version}/bin:$PATH \
&& kotlinc-native hello-world.kt -o hello-world
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
FROM registry.access.redhat.com/ubi7/ubi-minimal:latest AS run
COPY --from=build hello-world.kexe ./hello-world
CMD ./hello-world
fun main() {
println("Hello World, I'm Kotlin Native!")
}
@reitzig
Copy link
Author

reitzig commented May 25, 2020

For UBI 8:

FROM registry.access.redhat.com/ubi8/ubi:latest AS build

RUN yum -y install --disableplugin=subscription-manager \ 
        ncurses-compat-libs \
        java-11-openjdk

# snip

FROM registry.access.redhat.com/ubi8/ubi-minimal:latest AS run

@reitzig
Copy link
Author

reitzig commented Jun 15, 2020

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