[Java]基于Java21 Graavl VM 编译 Spring Boot 3.2 项目

使用含有GraavlVM的基础镜像 命令行 Gu 作为baseImage 编译 Java程序

## 这里的gakaki/spring_base:latest 就是之前制作的Docker镜像
## 可以用免费的Docker Hub 或者 gcr GitHub容器镜像仓库

FROM gakaki/spring_base:latest as builder

## 设置目录
WORKDIR /app
## copy java项目
COPY . .
## 用gradle编译
RUN  gradle nativeCompile
## 用maven编译
# RUN 
FROM debian:stable-slim

COPY --from=builder /etc/passwd /etc/passwd
COPY --from=builder /etc/group /etc/group

WORKDIR /app
EXPOSE 8080
## 暴露8080端口 把编译好的java 二进制程序到当前镜像 也可以用alpine或者bellsoft的
COPY --from=builder /app/build/native/nativeCompile/java ./
RUN ls
USER app:app
## 启动入口点
ENTRYPOINT ["/app/java"]


# below will say no such file or directory because not install musl c lib
# can not run may be no musl comporesd size 29mb
# FROM bellsoft/alpaquita-linux-base:stream-musl


# ok has musl but big 180mb
# FROM bellsoft/liberica-native-image-kit-container:jdk-17-nik-22.2-stream-musl

# FROM scratch and alpine need install muslc can not run


# FROM debian:stable-slim ok 56mb compressed ok has muslc
`
# muslc advantages generate smaller size binary and speed up fast in docker and arm 
# very usage for docker and arm