I have this Dockerfile:
FROM oracle/graalvm-ce:19.3.1-java11 as graalvm
RUN gu install native-image
COPY . /home/app/monolith
WORKDIR /home/app/monolith
RUN ./gradlew clean build
RUN native-image --no-server -cp build/libs/monolith-*-all.jar
FROM frolvlad/alpine-glibc
RUN apk update && apk add libstdc++
EXPOSE 8080
COPY --from=graalvm /home/app/monolith/monolith /app/monolith
ENTRYPOINT ["/app/monolith"]
It is quite simple. In the first stage it creates a native-image from the jar and in the second it uses a tiny alpine image to run that binary. I want to migrate it to bazel.
I pull both bases in my workspace like this:
container_pull (
name = "graalvm",
registry = "index.docker.io",
repository = "oracle/graalvm-ce",
tag = "20.0.0-java11",
)
container_pull (
name = "alpine_glibc",
registry = "index.docker.io",
repository = "frolvlad/alpine-glibc",
tag = "glibc-2.30",
)
After this I am not sure to use the first image with a java_library and inject the result into the second to generate the resulting image.