Update Dockerfile to use Maven image with domestic repository settings for improved dependency download speed.

This commit is contained in:
liu
2026-02-03 11:40:24 +08:00
parent caf0d97903
commit f3b6d6d948
2 changed files with 54 additions and 2 deletions

View File

@@ -1,8 +1,11 @@
# ========== 阶段一Maven 构建 ==========
FROM eclipse-temurin:8-jdk-alpine AS builder
# ========== 阶段一Maven 构建(使用带 Maven 的镜像 + 国内源) ==========
FROM maven:3.9-eclipse-temurin-8-alpine AS builder
WORKDIR /build
# 使用阿里云 Maven 镜像,加速依赖下载
COPY docker/maven-settings.xml /root/.m2/settings.xml
# 先只复制 pom利用 Docker 缓存依赖层
COPY pom.xml .
RUN mvn dependency:go-offline -B -q

49
docker/maven-settings.xml Normal file
View File

@@ -0,0 +1,49 @@
<?xml version="1.0" encoding="UTF-8"?>
<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">
<mirrors>
<mirror>
<id>aliyun-public</id>
<mirrorOf>*</mirrorOf>
<name>阿里云公共仓库</name>
<url>https://maven.aliyun.com/repository/public</url>
</mirror>
</mirrors>
<profiles>
<profile>
<id>aliyun</id>
<repositories>
<repository>
<id>aliyun-public</id>
<url>https://maven.aliyun.com/repository/public</url>
<releases><enabled>true</enabled></releases>
<snapshots><enabled>true</enabled></snapshots>
</repository>
<repository>
<id>aliyun-central</id>
<url>https://maven.aliyun.com/repository/central</url>
<releases><enabled>true</enabled></releases>
<snapshots><enabled>false</enabled></snapshots>
</repository>
<repository>
<id>aliyun-spring</id>
<url>https://maven.aliyun.com/repository/spring</url>
<releases><enabled>true</enabled></releases>
<snapshots><enabled>false</enabled></snapshots>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>aliyun-public</id>
<url>https://maven.aliyun.com/repository/public</url>
<releases><enabled>true</enabled></releases>
<snapshots><enabled>true</enabled></snapshots>
</pluginRepository>
</pluginRepositories>
</profile>
</profiles>
<activeProfiles>
<activeProfile>aliyun</activeProfile>
</activeProfiles>
</settings>