fix(build): Docker 构建阶段固定阿里云 Maven 中央镜像
容器内从 Maven Central 拉依赖时 maven-filtering:3.3.1 解析失败, 且 dependency:go-offline 被 || true 静默吞掉,导致发布时才暴露。 构建阶段写入 settings.xml 走阿里云 central 镜像,并让 go-offline 失败即中断。
This commit is contained in:
1 parent
272aa62434
commit
ddd2406f32
1 file changed
+15
-1
+15
-1
@@ -15,6 +15,20 @@
|
||||
FROM maven:3.9-eclipse-temurin-21 AS build
|
||||
WORKDIR /build
|
||||
|
||||
# Maven Central 在国内网络下拉依赖不稳定(构建时曾出现 maven-filtering:3.3.1 解析失败),
|
||||
# 构建阶段固定走阿里云 central 镜像;其它仓库仍直连。
|
||||
RUN mkdir -p /root/.m2 \
|
||||
&& printf '%s\n' \
|
||||
'<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0">' \
|
||||
' <mirrors>' \
|
||||
' <mirror>' \
|
||||
' <id>aliyun-central</id>' \
|
||||
' <mirrorOf>central</mirrorOf>' \
|
||||
' <url>https://maven.aliyun.com/repository/central</url>' \
|
||||
' </mirror>' \
|
||||
' </mirrors>' \
|
||||
'</settings>' > /root/.m2/settings.xml
|
||||
|
||||
# 先只拷各模块 pom 再拉依赖:依赖层可复用,改业务代码不会重新下载依赖
|
||||
COPY pom.xml .
|
||||
COPY fruitshorts-common/pom.xml fruitshorts-common/
|
||||
@@ -30,7 +44,7 @@ COPY fruitshorts-module-creator/pom.xml fruitshorts-module-creator/
|
||||
COPY fruitshorts-admin-api/pom.xml fruitshorts-admin-api/
|
||||
COPY fruitshorts-app-api/pom.xml fruitshorts-app-api/
|
||||
COPY fruitshorts-transcode-worker/pom.xml fruitshorts-transcode-worker/
|
||||
RUN mvn -B -q -DskipTests dependency:go-offline || true
|
||||
RUN mvn -B -q -DskipTests dependency:go-offline
|
||||
|
||||
COPY . .
|
||||
ARG MODULE=fruitshorts-app-api
|
||||
|
||||
Reference in new issue
Block a user