Created
April 2, 2023 13:07
-
-
Save ghostbear/1ae758bc3ced4de8d494690f9458c37d to your computer and use it in GitHub Desktop.
Spring Boot - Create your own native image without `bootBuildImage`
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
Simple `Dockerfile` script to generate a native image for a Spring Boot application | |
```dockerfile | |
FROM ghcr.io/graalvm/graalvm-ce:22.3.1 AS build | |
RUN microdnf install -y findutils | |
WORKDIR /app | |
COPY . ./ | |
RUN ./gradlew nativeCompile | |
FROM ubuntu AS app | |
COPY --from=build /app/build/native/nativeCompile/project-name /app/project-name | |
ENTRYPOINT /app/project-name | |
``` | |
`microdnf install -y findutils` is used to get nessesary dependecy such as `xargs` | |
`ubuntu` is used due to missing shared libraries in `alpine` but you can experiment to find a image that works for you. You can use `ENTRYPOINT ldd /app/project-name` to get a verbose error meassage |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment