Open alvarosanchez opened 3 years ago
How are these built in the maven plugin?
./mvn package -Dpackaging=docker-native -Dmicronaut.native-image.static=true
That uses the above Dockerfile
What base image is used?
oracle/graalvm-ce-$version-java11
This can be done with:
dockerfileNative {
baseImage = "gcr.io/distroless/cc-debian10"
}
nativeImage {
args("-H:+StaticExecutableWithDynamicLibC")
}
Not quite the same, those are "mostly static" native images, libc
is still required in the Docker base image
"Purely static", musl
based native images can be run without any other dependencies (i.e. FROM scratch
)
./mvn package -Dpackaging=docker-native -Dmicronaut.native-image.static=true
That uses the above
Dockerfile
How can I achieve this with Gradle?
@alvarosanchez am getting the below error
cp: cannot stat '/usr/lib/gcc/x86_64-redhat-linux/4.8.2/libstdc++.a': No such file or directory
The command '/bin/sh -c mkdir ${RESULT_LIB} && curl -L -o musl.tar.gz https://musl.libc.org/releases/musl-1.2.1.tar.gz && mkdir musl && tar -xzf musl.tar.gz -C musl --strip-components 1 && cd musl && ./configure --disable-shared --prefix=${RESULT_LIB} && make && make install && cd / && rm -rf /muscl && rm -f /musl.tar.gz && cp /usr/lib/gcc/x86_64-redhat-linux/4.8.2/libstdc++.a ${RESULT_LIB}/lib/' returned a non-zero code: 1
@binoysankar you have to take a look at the base image which version of libstdc++ is present.
This can't be done at this moment with the Gradle plugin out of the box. You have a few options:
For reference, this is a Dockerfile that works: https://github.com/micronaut-projects/micronaut-maven-plugin/blob/master/src/main/resources/dockerfiles/DockerfileNativeStatic