这个Dockerfile文件使用在如下场景中:
springboot项目编译打包生成jar包后,构建一个含有该jar包文件的镜像,推送到仓库
jar包运行需要java环境,实际上只需要jre环境就能运行jar包,采用如下基础镜像可最大化减小最终生成的镜像大小
比如如下生成的基础精选名称是:jre:1.8.0_275
FROM jeanblanchard/alpine-glibc:latest
MAINTAINER sandu <1103324414@qq.com>
#COPY localtime /etc/localtime
#COPY timezone /etc/timezone
RUN echo "https://mirrors.aliyun.com/alpine/latest-stable/main/" > /etc/apk/repositories
RUN echo "https://mirrors.aliyun.com/alpine/latest-stable/community/" >> /etc/apk/repositories
RUN ["apk","update"]
RUN ["apk","add","curl"]
RUN ["apk","add","openjdk8-jre"]
项目构建的Dockerfile文件内容
FROM jre:1.8.0_275
MAINTAINER 1103324414@qq.com
EXPOSE 8093
ADD target/app.jar app.jar
ENTRYPOINT ["java","-Djava.security.egd=file:/dev/./urandom", "-jar","app.jar"]
CMD ["--spring.profiles.active=test"]