fix: 更新Dockerfile以使用华为云镜像源并优化依赖安装步骤

This commit is contained in:
2025-10-23 16:15:33 +08:00
parent 2360504491
commit 3776a011ed

View File

@ -7,13 +7,17 @@ FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
ARG BUILD_CONFIGURATION=Release
ARG NODE_VERSION=16.13.0
ARG YARN_VERSION=1.22.15
RUN apt-get update -yq \
&& apt-get install -yq curl gnupg \
&& curl -sL https://deb.nodesource.com/setup_16.x | bash - \
&& apt-get install -yq nodejs \
&& npm install -g yarn@${YARN_VERSION} \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
RUN echo "deb https://mirrors.huaweicloud.com/debian/ bookworm main contrib non-free non-free-firmware" > /etc/apt/sources.list && \
echo "deb https://mirrors.huaweicloud.com/debian/ bookworm-updates main contrib non-free non-free-firmware" >> /etc/apt/sources.list && \
echo "deb https://mirrors.huaweicloud.com/debian/ bookworm-backports main contrib non-free non-free-firmware" >> /etc/apt/sources.list && \
echo "deb https://mirrors.huaweicloud.com/debian-security bookworm-security main contrib non-free non-free-firmware" >> /etc/apt/sources.list && \
apt-get update -yq && \
apt-get install -yq curl gnupg && \
curl -sL https://deb.nodesource.com/setup_16.x | bash - && \
apt-get install -yq nodejs && \
npm install -g yarn@${YARN_VERSION} && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*
ARG BUILD_CONFIGURATION=Release
WORKDIR /src
COPY ["NuGet.Config", "."]
@ -25,9 +29,11 @@ COPY ["shared/KonSoft.Shared.Localization/KonSoft.Shared.Localization.csproj", "
RUN dotnet restore "./applications/KonSoft.AuthServer/KonSoft.AuthServer.csproj"
COPY . .
WORKDIR "/src/applications/KonSoft.AuthServer"
RUN dotnet tool install -g Volo.Abp.Cli \
&& export PATH="$PATH:/root/.dotnet/tools" \
&& abp install-libs
RUN dotnet nuget locals all --clear
RUN dotnet nuget add source https://mirrors.huaweicloud.com/repository/nuget/v3/index.json -n HuaweiCloud
RUN dotnet tool install -g Volo.Abp.Cli --version 8.3.4
ENV PATH="$PATH:/root/.dotnet/tools"
RUN abp install-libs
RUN dotnet build "./KonSoft.AuthServer.csproj" -c $BUILD_CONFIGURATION -o /app/build
# 此阶段用于发布要复制到最终阶段的服务项目