feat: docker 构建失败问题解决,及docker构建文档

This commit is contained in:
fengxian.guo
2024-12-21 08:37:10 +08:00
parent 07a5b69511
commit 2cd8b73aa3
3 changed files with 28 additions and 0 deletions

View File

@@ -8,6 +8,8 @@ EXPOSE 8080
FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
ARG BUILD_CONFIGURATION=Release
WORKDIR /src
COPY ./common.props ./
COPY ["src/Yi.Abp.Web/Yi.Abp.Web.csproj", "src/Yi.Abp.Web/"]
COPY ["framework/Yi.Framework.AspNetCore.Authentication.OAuth/Yi.Framework.AspNetCore.Authentication.OAuth.csproj", "framework/Yi.Framework.AspNetCore.Authentication.OAuth/"]
COPY ["framework/Yi.Framework.AspNetCore/Yi.Framework.AspNetCore.csproj", "framework/Yi.Framework.AspNetCore/"]

View File

@@ -0,0 +1,22 @@
# Docker 构建说明
## 执行命令
```shell
# 在Yi.Abp.Net8 目录下执行
docker build -t xxx-xxx:${BUILD_NUMBER} -f ./src/Yi.Abp.Web/Dockerfile .
```
## 注意
NuGet 源国内访问有时候会报错,可以考虑切换成华为源,加上参数
```shell
RUN dotnet restore --source https://repo.huaweicloud.com/repository/nuget/v3/index.json "./src/Yi.Abp.Web/./Yi.Abp.Web.csproj"
RUN dotnet build --source https://repo.huaweicloud.com/repository/nuget/v3/index.json "./Yi.Abp.Web.csproj" -c $BUILD_CONFIGURATION -o /app/build
RUN dotnet publish --source https://repo.huaweicloud.com/repository/nuget/v3/index.json "./Yi.Abp.Web.csproj" -c $BUILD_CONFIGURATION -o /app/publish /p:UseAppHost=false
```

View File

@@ -10,6 +10,10 @@
<ItemGroup>
<PackageReference Include="Hangfire.MemoryStorage" Version="1.8.1.1" />
<PackageReference Include="Hangfire.Redis.StackExchange" Version="1.9.4" />
<!-- 解决 docker 构建冲突问题,冲突版本信息如下 -->
<!-- Yi.Abp.Web -> Hangfire.Redis.StackExchange 1.9.4 -> Hangfire.Core (>= 1.8.7) -->
<!-- Yi.Abp.Web -> Yi.Abp.Application -> Yi.Framework.Rbac.Application -> Volo.Abp.BackgroundJobs.HangFire 0.4.1 -> Volo.Abp.HangFire 0.4.1 -> Hangfire.AspNetCore 1.6.19 -> Hangfire.Core (= 1.6.19). -->
<PackageReference Include="Hangfire.Core" Version="1.8.14" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="8.0.3" />
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="8.0.3" />
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.19.6" />