JDK的Dockerfile

openjdk(https://openjdk.org/)

也可以用微软的 https://learn.microsoft.com/zh-cn/java/openjdk/download#openjdk-17

使用debian系统

bash 复制代码
FROM openjdk:17-slim
MAINTAINER xxx

ENV SCM_PARAMS=""
ENV JAVA_OPTS="$JAVA_OPTS -Dspring.profiles.active=dev -Djava.security.egd=file:/dev/./urandom"

ENV TZ PRC
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
#RUN ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime

RUN sed -i 's/deb.debian.org/mirrors.aliyun.com/g' /etc/apt/sources.list
RUN apt-get clean

RUN apt-get update \
	&& apt-get install -y locales apt-utils \
    && apt-get install -y --no-install-recommends vim \
    && apt-get install -y --no-install-recommends curl

ADD ./target/report-basic-*.jar /app.jar

EXPOSE 8080

ENTRYPOINT ["sh","-c","java -jar $JAVA_OPTS /app.jar $SCM_PARAMS"]

azul(https://www.azul.com/downloads/?version=java-17-lts\&package=jdk#zulu)

ubuntu

bash 复制代码
FROM azul/zulu-openjdk:17
MAINTAINER e-zhangjiawei01

ENV SCM_PARAMS=""
ENV JAVA_OPTS="$JAVA_OPTS -Dspring.profiles.active=dev -Djava.security.egd=file:/dev/./urandom"

ENV TZ PRC
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone

#https://developer.aliyun.com/mirror/ubuntu?spm=a2c6h.13651102.0.0.3e221b11iKr4j6
RUN sed -i 's/archive.ubuntu.com/mirrors.aliyun.com/g' /etc/apt/sources.list
RUN sed -i 's/security.ubuntu.com/mirrors.aliyun.com/g' /etc/apt/sources.list
#RUN sed -i 's/deb.debian.org/mirrors.aliyun.com/g' /etc/apt/sources.list
RUN apt-get clean
#
RUN apt-get update \
    && apt-get install -y locales apt-utils \
    && apt-get install -y --no-install-recommends vim \
    && apt-get install -y --no-install-recommends curl

ADD ./target/location-*.jar /app.jar

EXPOSE 8080
ENTRYPOINT ["sh","-c","java -jar $JAVA_OPTS /app.jar $SCM_PARAMS"]

debian:

bash 复制代码
FROM azul/zulu-openjdk-debian:17
MAINTAINER xxxx

ENV SCM_PARAMS=""
ENV JAVA_OPTS="$JAVA_OPTS -Dspring.profiles.active=dev -Djava.security.egd=file:/dev/./urandom"

ENV TZ PRC
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
#RUN ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime

RUN sed -i 's/deb.debian.org/mirrors.aliyun.com/g' /etc/apt/sources.list
RUN apt-get clean

RUN apt-get update \
	&& apt-get install -y locales apt-utils \
    && apt-get install -y --no-install-recommends vim \
    && apt-get install -y --no-install-recommends curl

ADD ./target/report-basic-*.jar /app.jar

EXPOSE 8080

ENTRYPOINT ["sh","-c","java -jar $JAVA_OPTS /app.jar $SCM_PARAMS"]

aws-corretto(https://docs.aws.amazon.com/corretto/latest/corretto-17-ug/downloads-list.html)

不建议

aws-linux 和centos类似的系统

bash 复制代码
FROM amazoncorretto:17
MAINTAINER xxxx

ENV SCM_PARAMS=""
ENV JAVA_OPTS="$JAVA_OPTS -Djava.security.egd=file:/dev/./urandom"

RUN ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime

# 移除已有的yum仓库文件

#RUN rm -f /etc/yum.repos.d/*
# 添加阿里云的yum仓库文件
#ADD ./Centos-7.repo /etc/yum.repos.d/
# 清理缓存并生成新的缓存
RUN yum clean all && yum makecache

RUN yum install -y vim \
    yum install -y curl

ADD ./target/report-basic-*.jar /app.jar


ENTRYPOINT ["sh","-c","java -jar $JAVA_OPTS /app.jar $SCM_PARAMS"]

sapmachine(https://sap.github.io/SapMachine/)

bash 复制代码
FROM sapmachine:17-jdk-ubuntu-noble

ENV SCM_PARAMS=""
ENV JAVA_OPTS="$JAVA_OPTS -Dspring.profiles.active=dev"

ENV TZ PRC
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone

RUN sed -i 's/archive.ubuntu.com/mirrors.aliyun.com/g' /etc/apt/sources.list.d/ubuntu.sources
RUN sed -i 's/security.ubuntu.com/mirrors.aliyun.com/g' /etc/apt/sources.list.d/ubuntu.sources
RUN apt-get clean

RUN apt-get update \
    && apt-get install -y locales apt-utils \
    && apt-get install -y --no-install-recommends vim \
    && apt-get install -y --no-install-recommends curl

ADD ./target/location-*.jar /app.jar

EXPOSE 8080

ENTRYPOINT ["sh","-c","java -jar $JAVA_OPTS /app.jar $SCM_PARAMS"]
相关推荐
TT哇29 分钟前
【Java EE初阶】计算机是如何⼯作的
java·redis·java-ee
专注VB编程开发20年35 分钟前
javascript的类,ES6模块写法在VSCODE中智能提示
开发语言·javascript·vscode
Fireworkitte7 小时前
Apache POI 详解 - Java 操作 Excel/Word/PPT
java·apache·excel
weixin-a153003083167 小时前
【playwright篇】教程(十七)[html元素知识]
java·前端·html
DCTANT7 小时前
【原创】国产化适配-全量迁移MySQL数据到OpenGauss数据库
java·数据库·spring boot·mysql·opengauss
Touper.8 小时前
SpringBoot -- 自动配置原理
java·spring boot·后端
黄雪超8 小时前
JVM——函数式语法糖:如何使用Function、Stream来编写函数式程序?
java·开发语言·jvm
ThetaarSofVenice8 小时前
对象的finalization机制Test
java·开发语言·jvm
思则变8 小时前
[Pytest] [Part 2]增加 log功能
开发语言·python·pytest
lijingguang8 小时前
在C#中根据URL下载文件并保存到本地,可以使用以下方法(推荐使用现代异步方式)
开发语言·c#