Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save ghostbear/1ae758bc3ced4de8d494690f9458c37d to your computer and use it in GitHub Desktop.
Save ghostbear/1ae758bc3ced4de8d494690f9458c37d to your computer and use it in GitHub Desktop.
Spring Boot - Create your own native image without `bootBuildImage`
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