docker发布配置
This commit is contained in:
parent
419abaf68c
commit
e4565a1b47
@ -1,25 +1,9 @@
|
|||||||
**/.classpath
|
|
||||||
**/.dockerignore
|
**/.dockerignore
|
||||||
**/.env
|
**/.env
|
||||||
**/.git
|
**/.git
|
||||||
**/.gitignore
|
**/.gitignore
|
||||||
**/.project
|
|
||||||
**/.settings
|
|
||||||
**/.toolstarget
|
|
||||||
**/.vs
|
**/.vs
|
||||||
**/.vscode
|
**/.vscode
|
||||||
**/*.*proj.user
|
|
||||||
**/*.dbmdl
|
|
||||||
**/*.jfm
|
|
||||||
**/azds.yaml
|
|
||||||
**/bin
|
**/bin
|
||||||
**/charts
|
|
||||||
**/docker-compose*
|
|
||||||
**/Dockerfile*
|
|
||||||
**/node_modules
|
|
||||||
**/npm-debug.log
|
|
||||||
**/obj
|
**/obj
|
||||||
**/secrets.dev.yaml
|
**/appsettings.Development.json
|
||||||
**/values.dev.yaml
|
|
||||||
LICENSE
|
|
||||||
README.md
|
|
||||||
|
|||||||
62
Dockerfile
62
Dockerfile
@ -1,40 +1,48 @@
|
|||||||
#See https://aka.ms/customizecontainer to learn how to customize your debug container and how Visual Studio uses this Dockerfile to build your images for faster debugging.
|
# 基于.NET 8官方Linux镜像的多阶段构建
|
||||||
|
FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS base
|
||||||
FROM mcr.microsoft.com/dotnet/aspnet:10.0 AS base
|
|
||||||
|
|
||||||
#修改apt-get源,加速apt下载
|
|
||||||
#RUN sed -i s@/deb.debian.org/@/mirrors.163.com/@g /etc/apt/sources.list.d/debian.sources
|
|
||||||
#RUN cat /etc/apt/sources.list
|
|
||||||
#安装fontconfig
|
|
||||||
RUN apt-get clean
|
|
||||||
RUN apt-get update
|
|
||||||
RUN apt-get install -y fontconfig
|
|
||||||
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
EXPOSE 8066
|
EXPOSE 9996
|
||||||
EXPOSE 443
|
|
||||||
|
|
||||||
FROM mcr.microsoft.com/dotnet/sdk:10.0 AS build
|
# 设置时区
|
||||||
|
ENV TZ=Asia/Shanghai
|
||||||
|
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
|
||||||
|
|
||||||
|
# 安装必要的依赖(如字体库,适配MiniExcel等)
|
||||||
|
RUN apt-get update && apt-get install -y fontconfig && apt-get clean
|
||||||
|
|
||||||
|
# 构建阶段
|
||||||
|
FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
|
||||||
|
ARG BUILD_CONFIGURATION=Release
|
||||||
WORKDIR /src
|
WORKDIR /src
|
||||||
COPY ["Easy.Admin.Web.Entry/Easy.Admin.Web.Entry.csproj", "Easy.Admin.Web.Entry/"]
|
|
||||||
COPY ["Easy.Admin.Web.Core/Easy.Admin.Web.Core.csproj", "Easy.Admin.Web.Core/"]
|
# 复制csproj文件并还原
|
||||||
COPY ["Easy.Admin.Application/Easy.Admin.Application.csproj", "Easy.Admin.Application/"]
|
COPY ["YD_Event.Web.Entry/YD_Event.Web.Entry.csproj", "YD_Event.Web.Entry/"]
|
||||||
COPY ["Easy.Admin.Core/Easy.Admin.Core.csproj", "Easy.Admin.Core/"]
|
COPY ["YD_Event.Web.Core/YD_Event.Web.Core.csproj", "YD_Event.Web.Core/"]
|
||||||
RUN dotnet restore "Easy.Admin.Web.Entry/Easy.Admin.Web.Entry.csproj"
|
COPY ["YD_Event.Application/YD_Event.Application.csproj", "YD_Event.Application/"]
|
||||||
|
COPY ["YD_Event.Core/YD_Event.Core.csproj", "YD_Event.Core/"]
|
||||||
|
|
||||||
|
RUN dotnet restore "YD_Event.Web.Entry/YD_Event.Web.Entry.csproj"
|
||||||
|
|
||||||
|
# 复制所有源码
|
||||||
COPY . .
|
COPY . .
|
||||||
WORKDIR "/src/Easy.Admin.Web.Entry"
|
WORKDIR "/src/YD_Event.Web.Entry"
|
||||||
RUN dotnet build "Easy.Admin.Web.Entry.csproj" -c Release -o /app/build
|
RUN dotnet build "YD_Event.Web.Entry.csproj" -c $BUILD_CONFIGURATION -o /app/build
|
||||||
|
|
||||||
|
# 发布阶段
|
||||||
FROM build AS publish
|
FROM build AS publish
|
||||||
RUN dotnet publish "Easy.Admin.Web.Entry.csproj" -c Release -o /app/publish /p:UseAppHost=false
|
ARG BUILD_CONFIGURATION=Release
|
||||||
|
RUN dotnet publish "YD_Event.Web.Entry.csproj" -c $BUILD_CONFIGURATION -o /app/publish /p:UseAppHost=false
|
||||||
|
|
||||||
|
# 运行阶段
|
||||||
FROM base AS final
|
FROM base AS final
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
COPY --from=publish /app/publish .
|
COPY --from=publish /app/publish .
|
||||||
|
|
||||||
# 设置时区
|
# 配置Kestrel端口
|
||||||
ENV TZ=Asia/Shanghai
|
ENV ASPNETCORE_URLS=http://*:9996
|
||||||
ENV ASPNETCORE_URLS 'http://*:8066'
|
|
||||||
|
|
||||||
ENTRYPOINT ["dotnet", "Easy.Admin.Web.Entry.dll"]
|
# 健康检查
|
||||||
|
HEALTHCHECK --interval=30s --timeout=30s --start-period=5s --retries=3 \
|
||||||
|
CMD curl -f http://localhost:9996/health || exit 1
|
||||||
|
|
||||||
|
ENTRYPOINT ["dotnet", "YD_Event.Web.Entry.dll"]
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
using Furion;
|
using Furion;
|
||||||
using Microsoft.AspNetCore.Builder;
|
using Microsoft.AspNetCore.Builder;
|
||||||
using Microsoft.AspNetCore.Hosting;
|
using Microsoft.AspNetCore.Hosting;
|
||||||
using Microsoft.AspNetCore.Http;
|
using Microsoft.AspNetCore.Http;
|
||||||
@ -60,6 +60,8 @@ public class Startup : AppStartup
|
|||||||
});
|
});
|
||||||
services.AddConsoleFormatter();
|
services.AddConsoleFormatter();
|
||||||
|
|
||||||
|
// 添加健康检查
|
||||||
|
services.AddHealthChecks();
|
||||||
|
|
||||||
// 全局日志 文档:http://furion.baiqian.ltd/docs/logging/#18116-%E8%BE%93%E5%87%BA-json-%E6%94%AF%E6%8C%81%E5%BF%BD%E7%95%A5%E5%B1%9E%E6%80%A7%E5%90%8D%E6%88%96%E5%B1%9E%E6%80%A7%E7%B1%BB%E5%9E%8B
|
// 全局日志 文档:http://furion.baiqian.ltd/docs/logging/#18116-%E8%BE%93%E5%87%BA-json-%E6%94%AF%E6%8C%81%E5%BF%BD%E7%95%A5%E5%B1%9E%E6%80%A7%E5%90%8D%E6%88%96%E5%B1%9E%E6%80%A7%E7%B1%BB%E5%9E%8B
|
||||||
services.AddMonitorLogging(options =>
|
services.AddMonitorLogging(options =>
|
||||||
@ -215,6 +217,7 @@ public class Startup : AppStartup
|
|||||||
|
|
||||||
app.UseEndpoints(endpoints =>
|
app.UseEndpoints(endpoints =>
|
||||||
{
|
{
|
||||||
|
endpoints.MapHealthChecks("/health");
|
||||||
endpoints.MapControllers();
|
endpoints.MapControllers();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1 +1,8 @@
|
|||||||
Serve.Run(RunOptions.Default.WithArgs(args));
|
Serve.Run(RunOptions.Default
|
||||||
|
.WithArgs(args)
|
||||||
|
.ConfigureBuilder(builder =>
|
||||||
|
{
|
||||||
|
// 确保容器内绑定到所有IP,端口9996
|
||||||
|
builder.WebHost.UseUrls("http://*:9996");
|
||||||
|
})
|
||||||
|
);
|
||||||
|
|||||||
@ -0,0 +1,15 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<!-- https://go.microsoft.com/fwlink/?LinkID=208121. -->
|
||||||
|
<Project>
|
||||||
|
<PropertyGroup>
|
||||||
|
<DeleteExistingFiles>false</DeleteExistingFiles>
|
||||||
|
<ExcludeApp_Data>false</ExcludeApp_Data>
|
||||||
|
<LaunchSiteAfterPublish>true</LaunchSiteAfterPublish>
|
||||||
|
<LastUsedBuildConfiguration>Release</LastUsedBuildConfiguration>
|
||||||
|
<LastUsedPlatform>Any CPU</LastUsedPlatform>
|
||||||
|
<PublishProvider>FileSystem</PublishProvider>
|
||||||
|
<PublishUrl>D:\发布\EventServer</PublishUrl>
|
||||||
|
<WebPublishMethod>FileSystem</WebPublishMethod>
|
||||||
|
<_TargetId>Folder</_TargetId>
|
||||||
|
</PropertyGroup>
|
||||||
|
</Project>
|
||||||
@ -5,5 +5,6 @@
|
|||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<ActiveDebugProfile>YD_Event.Web.Entry</ActiveDebugProfile>
|
<ActiveDebugProfile>YD_Event.Web.Entry</ActiveDebugProfile>
|
||||||
|
<NameOfLastUsedPublishProfile>F:\项目\YD\YD_Event.Admin\YD_Event.Web.Entry\Properties\PublishProfiles\FolderProfile.pubxml</NameOfLastUsedPublishProfile>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
</Project>
|
</Project>
|
||||||
@ -7,6 +7,13 @@
|
|||||||
"Microsoft.EntityFrameworkCore": "Information"
|
"Microsoft.EntityFrameworkCore": "Information"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"Kestrel": {
|
||||||
|
"Endpoints": {
|
||||||
|
"Http": {
|
||||||
|
"Url": "http://*:9996"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"AllowedHosts": "*",
|
"AllowedHosts": "*",
|
||||||
"ConnectionConfigs": [
|
"ConnectionConfigs": [
|
||||||
{
|
{
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user