Configure npm and Maven to use Chinese mirrors for improved package retrieval speed in Dockerfile
This commit is contained in:
@@ -3,6 +3,9 @@ FROM node:20-alpine AS frontend-builder
|
||||
|
||||
WORKDIR /app/frontend
|
||||
|
||||
# 配置 npm 使用淘宝镜像源
|
||||
RUN npm config set registry https://registry.npmmirror.com
|
||||
|
||||
COPY frontend/package.json frontend/package-lock.json* ./
|
||||
RUN npm ci --ignore-scripts || npm install --legacy-peer-deps
|
||||
|
||||
@@ -17,6 +20,22 @@ WORKDIR /app
|
||||
# 安装 Maven
|
||||
RUN apk add --no-cache maven
|
||||
|
||||
# 配置 Maven 使用阿里云镜像源
|
||||
RUN mkdir -p /root/.m2 && \
|
||||
echo '<?xml version="1.0" encoding="UTF-8"?>' > /root/.m2/settings.xml && \
|
||||
echo '<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"' >> /root/.m2/settings.xml && \
|
||||
echo ' xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"' >> /root/.m2/settings.xml && \
|
||||
echo ' xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">' >> /root/.m2/settings.xml && \
|
||||
echo ' <mirrors>' >> /root/.m2/settings.xml && \
|
||||
echo ' <mirror>' >> /root/.m2/settings.xml && \
|
||||
echo ' <id>aliyunmaven</id>' >> /root/.m2/settings.xml && \
|
||||
echo ' <mirrorOf>*</mirrorOf>' >> /root/.m2/settings.xml && \
|
||||
echo ' <name>阿里云公共仓库</name>' >> /root/.m2/settings.xml && \
|
||||
echo ' <url>https://maven.aliyun.com/repository/public</url>' >> /root/.m2/settings.xml && \
|
||||
echo ' </mirror>' >> /root/.m2/settings.xml && \
|
||||
echo ' </mirrors>' >> /root/.m2/settings.xml && \
|
||||
echo '</settings>' >> /root/.m2/settings.xml
|
||||
|
||||
COPY backend/ ./backend/
|
||||
COPY --from=frontend-builder /app/frontend/dist ./backend/src/main/resources/static
|
||||
|
||||
|
||||
Reference in New Issue
Block a user