我是靠谱客的博主 欣喜雪糕,最近开发中收集的这篇文章主要介绍基于干净的ubuntu或者debian构建java环境或者构建mvn环境,觉得挺不错的,现在分享给大家,希望可以做个参考。

概述

debian版本

版本名称版本号Docker镜像描述
bullseye11debian:bullseye、debian:bullseye-slim当前的稳定(stable)版
buster10debian:buster、debian:buster-slim当前的旧的稳定(oldstable)版
stretch9debian:stretch、debian:stretch-slim更旧的稳定(oldoldstable)版,现有长期支持
jessie8debian:jessie已存档版本,现有扩展长期支持
wheezy7debian:wheezy被淘汰的稳定版
squeeze6.0debian:squeeze被淘汰的稳定版
lenny5.0debian:lenny被淘汰的稳定版
etch4.0debian:etch被淘汰的稳定版
sarge3.1debian:sarge被淘汰的稳定版
woody3.0debian:woody被淘汰的稳定版
potato2.2debian:potato被淘汰的稳定版
slink2.1debian:slink被淘汰的稳定版
hamm2.0debian:hamm被淘汰的稳定版

Ubuntu版本

版本名称版本号Docker镜像
precise12.04ubuntu:12.04
quantal12.10ubuntu:12.10
trusty14.04ubuntu:14.04
utopic14.10ubuntu:14.10
vivid15.04ubuntu:15.04
wily15.10ubuntu:15.10
xenial16.04ubuntu:16.04
yakkety16.10ubuntu:16.10
bionic18.04ubuntu:18.04
cosmic18.10ubuntu:18.10
focal20.04ubuntu:20.04
groovy20.10ubuntu:20.10
jammy22.04ubuntu:22.04
kinetic22.10ubuntu:22.10
lunar23.04ubuntu:23.04

构建「构建环境」镜像

FROM ubuntu:22.10
ENV JAVA_HOME=/opt/jdk8u352-b08
ENV M2_HOME=/opt/apache-maven-3.8.6
ENV PATH=$JAVA_HOME/bin:$M2_HOME/bin:$PATH
ADD OpenJDK8U-jdk_x64_linux_hotspot_8u352b08.tar.gz /opt/
ADD apache-maven-3.8.6-bin.tar.gz /opt/
RUN 
echo "deb http://mirrors.cloud.tencent.com/ubuntu/ kinetic main restricted universe multiverse" > /etc/apt/sources.list && 
echo "deb http://mirrors.cloud.tencent.com/ubuntu/ kinetic-security main restricted universe multiverse" >> /etc/apt/sources.list && 
echo "deb http://mirrors.cloud.tencent.com/ubuntu/ kinetic-updates main restricted universe multiverse" >> /etc/apt/sources.list && 
echo "deb http://mirrors.cloud.tencent.com/ubuntu/ kinetic-backports main restricted universe multiverse" >> /etc/apt/sources.list && 
echo "deb http://mirrors.cloud.tencent.com/ubuntu/ kinetic-proposed main restricted universe multiverse" >> /etc/apt/sources.list && 
echo "deb-src http://mirrors.cloud.tencent.com/ubuntu/ kinetic main restricted universe multiverse" >> /etc/apt/sources.list && 
echo "deb-src http://mirrors.cloud.tencent.com/ubuntu/ kinetic-security main restricted universe multiverse" >> /etc/apt/sources.list && 
echo "deb-src http://mirrors.cloud.tencent.com/ubuntu/ kinetic-updates main restricted universe multiverse" >> /etc/apt/sources.list && 
echo "deb-src http://mirrors.cloud.tencent.com/ubuntu/ kinetic-backports main restricted universe multiverse" >> /etc/apt/sources.list && 
echo "deb-src http://mirrors.cloud.tencent.com/ubuntu/ kinetic-proposed main restricted universe multiverse" >> /etc/apt/sources.list
COPY settings.xml /root/.m2/

如果基础镜像采用了Debian,则在执行apt-update时会出现如下的异常:

# apt-get update
Get:1 http://mirrors.cloud.tencent.com/ubuntu kinetic InRelease [267 kB]
Get:2 http://mirrors.cloud.tencent.com/ubuntu kinetic-security InRelease [109 kB]
Get:3 http://mirrors.cloud.tencent.com/ubuntu kinetic-updates InRelease [109 kB]
Err:1 http://mirrors.cloud.tencent.com/ubuntu kinetic InRelease
The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 871920D1991BC93C
Err:2 http://mirrors.cloud.tencent.com/ubuntu kinetic-security InRelease
The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 871920D1991BC93C
Err:3 http://mirrors.cloud.tencent.com/ubuntu kinetic-updates InRelease
The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 871920D1991BC93C
Get:4 http://mirrors.cloud.tencent.com/ubuntu kinetic-backports InRelease [99.9 kB]
Err:4 http://mirrors.cloud.tencent.com/ubuntu kinetic-backports InRelease
The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 871920D1991BC93C
Get:5 http://mirrors.cloud.tencent.com/ubuntu kinetic-proposed InRelease [267 kB]
Err:5 http://mirrors.cloud.tencent.com/ubuntu kinetic-proposed InRelease
The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 871920D1991BC93C
Reading package lists... Done
W: GPG error: http://mirrors.cloud.tencent.com/ubuntu kinetic InRelease: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 871920D1991BC93C
E: The repository 'http://mirrors.cloud.tencent.com/ubuntu kinetic InRelease' is not signed.
N: Updating from such a repository can't be done securely, and is therefore disabled by default.
N: See apt-secure(8) manpage for repository creation and user configuration details.
W: GPG error: http://mirrors.cloud.tencent.com/ubuntu kinetic-security InRelease: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 871920D1991BC93C
E: The repository 'http://mirrors.cloud.tencent.com/ubuntu kinetic-security InRelease' is not signed.
N: Updating from such a repository can't be done securely, and is therefore disabled by default.
N: See apt-secure(8) manpage for repository creation and user configuration details.
W: GPG error: http://mirrors.cloud.tencent.com/ubuntu kinetic-updates InRelease: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 871920D1991BC93C
E: The repository 'http://mirrors.cloud.tencent.com/ubuntu kinetic-updates InRelease' is not signed.
N: Updating from such a repository can't be done securely, and is therefore disabled by default.
N: See apt-secure(8) manpage for repository creation and user configuration details.
W: GPG error: http://mirrors.cloud.tencent.com/ubuntu kinetic-backports InRelease: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 871920D1991BC93C
E: The repository 'http://mirrors.cloud.tencent.com/ubuntu kinetic-backports InRelease' is not signed.
N: Updating from such a repository can't be done securely, and is therefore disabled by default.
N: See apt-secure(8) manpage for repository creation and user configuration details.
W: GPG error: http://mirrors.cloud.tencent.com/ubuntu kinetic-proposed InRelease: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 871920D1991BC93C
E: The repository 'http://mirrors.cloud.tencent.com/ubuntu kinetic-proposed InRelease' is not signed.
N: Updating from such a repository can't be done securely, and is therefore disabled by default.
N: See apt-secure(8) manpage for repository creation and user configuration details.

可以使用如下办法

apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 871920D1991BC93C

如果有其他PUBKEY不可用,则采用同样的方法解决,注意apt-key需要使用旧的源安装好

构建「运行环境」镜像

FROM ubuntu:22.10
ENV JAVA_HOME=/opt/jdk8u352-b08
ENV M2_HOME=/opt/apache-maven-3.8.6
ENV PATH=$JAVA_HOME/bin:$M2_HOME/bin:$PATH
ADD OpenJDK8U-jdk_x64_linux_hotspot_8u352b08.tar.gz /opt/
RUN 
echo "deb http://mirrors.cloud.tencent.com/ubuntu/ kinetic main restricted universe multiverse" > /etc/apt/sources.list && 
echo "deb http://mirrors.cloud.tencent.com/ubuntu/ kinetic-security main restricted universe multiverse" >> /etc/apt/sources.list && 
echo "deb http://mirrors.cloud.tencent.com/ubuntu/ kinetic-updates main restricted universe multiverse" >> /etc/apt/sources.list && 
echo "deb http://mirrors.cloud.tencent.com/ubuntu/ kinetic-backports main restricted universe multiverse" >> /etc/apt/sources.list && 
echo "deb http://mirrors.cloud.tencent.com/ubuntu/ kinetic-proposed main restricted universe multiverse" >> /etc/apt/sources.list && 
echo "deb-src http://mirrors.cloud.tencent.com/ubuntu/ kinetic main restricted universe multiverse" >> /etc/apt/sources.list && 
echo "deb-src http://mirrors.cloud.tencent.com/ubuntu/ kinetic-security main restricted universe multiverse" >> /etc/apt/sources.list && 
echo "deb-src http://mirrors.cloud.tencent.com/ubuntu/ kinetic-updates main restricted universe multiverse" >> /etc/apt/sources.list && 
echo "deb-src http://mirrors.cloud.tencent.com/ubuntu/ kinetic-backports main restricted universe multiverse" >> /etc/apt/sources.list && 
echo "deb-src http://mirrors.cloud.tencent.com/ubuntu/ kinetic-proposed main restricted universe multiverse" >> /etc/apt/sources.list

使用案例

FROM build-env:v1 as Builder
WORKDIR /work
COPY . /work/
RUN mvn -q clean package -DskipTests
FROM runtime-env:v1
WORKDIR /work
COPY --from=Builder /work/xxx.tgz /work
RUN tar xf xxx.tgz -C /work && 
rm -fr /work/xxx.tgz
EXPOSE 8080
ENTRYPOINT bash /work/limiter/run.sh run com.to.path.XXXApplication pro

如此,可以构建一个相对干净的运行环境。

最后

以上就是欣喜雪糕为你收集整理的基于干净的ubuntu或者debian构建java环境或者构建mvn环境的全部内容,希望文章能够帮你解决基于干净的ubuntu或者debian构建java环境或者构建mvn环境所遇到的程序开发问题。

如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(58)

评论列表共有 0 条评论

立即
投稿
返回
顶部