构建Graal镜像的用意就是利用docker特性,无须在本地开发环境安装Graal,就可以编译spring应用或者quarkus应用
wget http://apache-mirror.rbc.ru/pub/apache/maven/maven-3/3.6.3/binaries/apache-maven-3.6.3-bin.tar.gz
我这里用的是apache-maven-3.6.3-bin.tar.gz,最开始用的apache-maven-3.3.9,执行mvn-Pnative package命令的时候提示报错
2. 准备settings.xml改成国内镜像地址,在容器内下jar会快一些
3. 编写Dockerfile文件
基础镜像可以到docker hub上自行选择,
FROM findepi/graalvm:java8-native #基础镜像可以自行选择
MAINTAINER alex
COPY apache-maven-3.6.3-bin.tar.gz .
RUN tar xzvf apache-maven-3.6.3-bin.tar.gz
COPY settings.xml apache-maven-3.6.3/conf/
RUN mv apache-maven-3.6.3 /usr/local/bin
RUN rm -f /apache-maven-3.6.3-bin.tar.gz
RUN export PATH=apache-maven-3.6.3/bin:$PATH
RUN export PATH=/usr/local/bin/apache-maven-3.6.3/bin:$PATH
RUN ln -s /usr/local/bin/apache-maven-3.6.3/bin/mvn /usr/local/bin/mvn
RUN echo $PATH && mvn -v
docker build ./env/ -t native-base-java8
start.sh
#!/bin/sh
cd /project
mvn clean -Pnative package
docker run --name=native-base-java8 -v /home/soft/gs-rest-service/complete/maven-repo:/maven-repo \
-v /home/soft/getting-started:/project -v ./start.sh:/start.sh \
native-base-java8 /start.sh
最后native是否生成,可以去看mvn执行日志
这里主要构建一环境,去执行 mvn clean -Pnative package