feat: 新增 compile-maven3 编译镜像(jdk17/jdk21/jdk25),Maven 走阿里云源
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
# 由 build.sh 预下载的 Maven 压缩包经 ADD 解压进镜像,
|
||||
# ADD 的源文件必须在构建上下文内,因此 *.tar.gz 不能在这里忽略
|
||||
build.sh
|
||||
.git/
|
||||
.DS_Store
|
||||
@@ -0,0 +1,3 @@
|
||||
# 构建产物 / 本地缓存
|
||||
*.tar.gz
|
||||
.DS_Store
|
||||
@@ -0,0 +1,25 @@
|
||||
FROM registry.cn-shanghai.aliyuncs.com/odboy/kenaito:runtime-jdk21
|
||||
LABEL MAINTAINER="tianjun@odboy.cn"
|
||||
ENV TimeZone=Asia/Shanghai
|
||||
ENV MAVEN_HOME=/usr/local/maven3
|
||||
ENV PATH="${MAVEN_HOME}/bin:$PATH"
|
||||
WORKDIR /home/admin
|
||||
# https://archive.apache.org/dist/maven/maven-3/3.9.9/binaries/apache-maven-3.9.9-bin.tar.gz
|
||||
# 由 build.sh 预先下载到本目录;bin.tar.gz 解包即为 apache-maven-3.9.9/
|
||||
ADD apache-maven-3.9.9-bin.tar.gz /usr/local/
|
||||
# make/gcc:编译含 jni/本地库的依赖;git:maven-scm / jgit 插件;
|
||||
# sysstat/net-tools:排障;tar/wget 若基础镜像未带也一并装上
|
||||
RUN set -e && yum install \
|
||||
make \
|
||||
gcc \
|
||||
git \
|
||||
tar \
|
||||
wget \
|
||||
sysstat \
|
||||
net-tools -y; \
|
||||
mv /usr/local/apache-maven-3.9.9 ${MAVEN_HOME}; \
|
||||
chmod +x ${MAVEN_HOME}/bin/*; \
|
||||
mvn -v;
|
||||
# 阿里云 Maven 镜像(覆盖 central),构建时不依赖 repo1.maven.org 的公网速度
|
||||
# 用 COPY 而非 ADD/ONBUILD:放在 Maven 安装之后,避免覆盖安装包自带的 conf/settings.xml
|
||||
COPY settings.xml ${MAVEN_HOME}/conf/settings.xml
|
||||
Executable
+16
@@ -0,0 +1,16 @@
|
||||
#!/usr/bin/env bash
|
||||
# 先下载 Maven 到当前目录,再基于本地文件构建镜像
|
||||
set -euo pipefail
|
||||
cd "$(dirname "$0")"
|
||||
|
||||
DIST=apache-maven-3.9.9-bin.tar.gz
|
||||
# 每个版本发布后都会留在 archive 上,用它比 dlcdn 稳定(dlcdn 只保留最新版本)
|
||||
URL=https://archive.apache.org/dist/maven/maven-3/3.9.9/binaries/${DIST}
|
||||
|
||||
if [ ! -f "${DIST}" ]; then
|
||||
curl -fL -o "${DIST}" "${URL}"
|
||||
fi
|
||||
|
||||
IMAGE=registry.cn-shanghai.aliyuncs.com/odboy/kenaito:compile-maven3-jdk21
|
||||
docker build -t "${IMAGE}" .
|
||||
docker push "${IMAGE}"
|
||||
@@ -0,0 +1,77 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
Maven 全局配置(镜像内 ${MAVEN_HOME}/conf/settings.xml)。
|
||||
只改镜像源,其余保持 Maven 默认行为;本地仓库仍是 ~/.m2/repository,
|
||||
构建时挂载 -v ~/.m2:/home/admin/.m2 即可复用宿主机缓存。
|
||||
可选环境变量:
|
||||
MAVEN_OPTS JVM 参数,如 -Xmx2g
|
||||
MAVEN_ARGS Maven 4 的通用参数;Maven 3.9 起也支持(如 -B)
|
||||
-->
|
||||
<settings xmlns="http://maven.apache.org/SETTINGS/1.2.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.2.0 https://maven.apache.org/xsd/settings-1.2.0.xsd">
|
||||
|
||||
<!-- 阿里云镜像同时代理 central 与几个常用仓库;<mirrorOf>*</mirrorOf> 会连项目里自建的
|
||||
private 仓库一起劫持,这里只代理 central,其余仓库仍按项目本身的配置访问 -->
|
||||
<mirrors>
|
||||
<mirror>
|
||||
<id>aliyun-public</id>
|
||||
<mirrorOf>central</mirrorOf>
|
||||
<name>Aliyun public</name>
|
||||
<url>https://maven.aliyun.com/repository/public</url>
|
||||
</mirror>
|
||||
<mirror>
|
||||
<id>aliyun-spring</id>
|
||||
<mirrorOf>spring-milestones,spring-snapshots</mirrorOf>
|
||||
<name>Aliyun spring</name>
|
||||
<url>https://maven.aliyun.com/repository/spring</url>
|
||||
</mirror>
|
||||
</mirrors>
|
||||
|
||||
<profiles>
|
||||
<!-- 保留 Maven 内建的默认 profile 名,让 aliyun 镜像对 central 生效并优先于内置配置 -->
|
||||
<profile>
|
||||
<id>aliyun</id>
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>central</id>
|
||||
<url>https://maven.aliyun.com/repository/public</url>
|
||||
<releases>
|
||||
<enabled>true</enabled>
|
||||
</releases>
|
||||
<snapshots>
|
||||
<enabled>false</enabled>
|
||||
</snapshots>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>spring-milestones</id>
|
||||
<url>https://maven.aliyun.com/repository/spring</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>spring-snapshots</id>
|
||||
<url>https://maven.aliyun.com/repository/spring</url>
|
||||
<snapshots>
|
||||
<enabled>true</enabled>
|
||||
</snapshots>
|
||||
</repository>
|
||||
</repositories>
|
||||
<pluginRepositories>
|
||||
<pluginRepository>
|
||||
<id>central</id>
|
||||
<url>https://maven.aliyun.com/repository/public</url>
|
||||
<releases>
|
||||
<enabled>true</enabled>
|
||||
</releases>
|
||||
<snapshots>
|
||||
<enabled>false</enabled>
|
||||
</snapshots>
|
||||
</pluginRepository>
|
||||
</pluginRepositories>
|
||||
</profile>
|
||||
</profiles>
|
||||
|
||||
<activeProfiles>
|
||||
<activeProfile>aliyun</activeProfile>
|
||||
</activeProfiles>
|
||||
|
||||
</settings>
|
||||
Reference in New Issue
Block a user