build(backend): 添加阿里云Maven镜像加速Docker构建并修复SSL问题
新增backend目录下的Maven镜像配置文件settings.xml,修改对应Dockerfile将配置复制到构建容器中,解决直连境外Maven中央仓库的SSL握手失败问题,同时加速依赖包下载。
This commit is contained in:
parent
8cf9e208e4
commit
ca00727cd0
|
|
@ -3,6 +3,9 @@ FROM maven:3.8.6-openjdk-8 AS builder
|
||||||
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
|
# 配置阿里云 Maven 镜像(容器内加速依赖下载,避免直连境外中央仓库 SSL 失败)
|
||||||
|
COPY settings.xml /root/.m2/settings.xml
|
||||||
|
|
||||||
# 复制 pom.xml 并下载依赖(利用 Docker 缓存)
|
# 复制 pom.xml 并下载依赖(利用 Docker 缓存)
|
||||||
COPY pom.xml .
|
COPY pom.xml .
|
||||||
RUN mvn dependency:go-offline
|
RUN mvn dependency:go-offline
|
||||||
|
|
|
||||||
17
backend/settings.xml
Normal file
17
backend/settings.xml
Normal file
|
|
@ -0,0 +1,17 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!--
|
||||||
|
专供 Docker 构建容器内 Maven 使用:将所有仓库请求镜像到阿里云,
|
||||||
|
避免直连境外 Maven 中央仓库(repo.maven.apache.org)出现 SSL 握手失败 / 超时。
|
||||||
|
-->
|
||||||
|
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 https://maven.apache.org/xsd/settings-1.0.0.xsd">
|
||||||
|
<mirrors>
|
||||||
|
<mirror>
|
||||||
|
<id>aliyun-public</id>
|
||||||
|
<mirrorOf>*</mirrorOf>
|
||||||
|
<name>Aliyun Public Repository</name>
|
||||||
|
<url>https://maven.aliyun.com/repository/public</url>
|
||||||
|
</mirror>
|
||||||
|
</mirrors>
|
||||||
|
</settings>
|
||||||
Loading…
Reference in New Issue
Block a user