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"]
相关推荐
A尘埃4 分钟前
SpringBoot的数据访问
java·spring boot·后端
yang-23075 分钟前
端口冲突的解决方案以及SpringBoot自动检测可用端口demo
java·spring boot·后端
沉登c6 分钟前
幂等性接口实现
java·rpc
代码之光_198017 分钟前
SpringBoot校园资料分享平台:设计与实现
java·spring boot·后端
wjs20241 小时前
XSLT 实例:掌握 XML 转换的艺术
开发语言
萧鼎1 小时前
Python第三方库选择与使用陷阱避免
开发语言·python
安冬的码畜日常1 小时前
【D3.js in Action 3 精译_029】3.5 给 D3 条形图加注图表标签(上)
开发语言·前端·javascript·信息可视化·数据可视化·d3.js
一颗星星辰1 小时前
C语言 | 第十章 | 函数 作用域
c语言·开发语言
lxp1997411 小时前
php函数积累
开发语言·php
科技资讯早知道1 小时前
java计算机毕设课设—坦克大战游戏
java·开发语言·游戏·毕业设计·课程设计·毕设