修改提交Dockerfile
This commit is contained in:
parent
67992af570
commit
a4f03cfbc1
25
.dockerignore
Normal file
25
.dockerignore
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
**/.dockerignore
|
||||||
|
**/.env
|
||||||
|
**/.git
|
||||||
|
**/.gitignore
|
||||||
|
**/.project
|
||||||
|
**/.settings
|
||||||
|
**/.toolstarget
|
||||||
|
**/.vs
|
||||||
|
**/.vscode
|
||||||
|
**/.idea
|
||||||
|
**/*.*proj.user
|
||||||
|
**/*.dbmdl
|
||||||
|
**/*.jfm
|
||||||
|
**/azds.yaml
|
||||||
|
**/bin
|
||||||
|
**/charts
|
||||||
|
**/docker-compose*
|
||||||
|
**/Dockerfile*
|
||||||
|
**/node_modules
|
||||||
|
**/npm-debug.log
|
||||||
|
**/obj
|
||||||
|
**/secrets.dev.yaml
|
||||||
|
**/values.dev.yaml
|
||||||
|
LICENSE
|
||||||
|
README.md
|
||||||
@ -1,21 +1,29 @@
|
|||||||
FROM mcr.microsoft.com/dotnet/aspnet:5.0 AS base
|
FROM mcr.microsoft.com/dotnet/aspnet:7.0 AS base
|
||||||
#创建 /app文件夹
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
#创建挂载目录,用于将程序部署在服务器本地
|
EXPOSE 80
|
||||||
#VOLUME /app
|
EXPOSE 443
|
||||||
#设置docker容器对外暴露端口
|
|
||||||
EXPOSE 8888
|
|
||||||
VOLUME /app/logs
|
|
||||||
#COPY bin/Release/net5.0/publish/ app/
|
|
||||||
COPY . app/
|
|
||||||
|
|
||||||
#设置容器内的时区,如果不设置,默认时区是标准时间比北京时间晚8个小时
|
FROM mcr.microsoft.com/dotnet/sdk:7.0 AS build
|
||||||
RUN echo "Asia/shanghai" > /etc/timezone
|
WORKDIR /src
|
||||||
RUN cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
|
COPY ["ZR.Admin.WebApi/ZR.Admin.WebApi.csproj", "ZR.Admin.WebApi/"]
|
||||||
|
COPY ["ZR.CodeGenerator/ZR.CodeGenerator.csproj", "ZR.CodeGenerator/"]
|
||||||
|
COPY ["Infrastructure/ZR.Infrastructure.csproj", "Infrastructure/"]
|
||||||
|
COPY ["ZR.Common/ZR.Common.csproj", "ZR.Common/"]
|
||||||
|
COPY ["ZR.ServiceCore/ZR.ServiceCore.csproj", "ZR.ServiceCore/"]
|
||||||
|
COPY ["ZR.Repository/ZR.Repository.csproj", "ZR.Repository/"]
|
||||||
|
COPY ["ZR.Model/ZR.Model.csproj", "ZR.Model/"]
|
||||||
|
COPY ["ZR.Service/ZR.Service.csproj", "ZR.Service/"]
|
||||||
|
COPY ["ZR.Tasks/ZR.Tasks.csproj", "ZR.Tasks/"]
|
||||||
|
COPY ["ZR.Admin.Grpc/ZR.Admin.Grpc.csproj", "ZR.Admin.Grpc/"]
|
||||||
|
RUN dotnet restore "ZR.Admin.WebApi/ZR.Admin.WebApi.csproj"
|
||||||
|
COPY . .
|
||||||
|
WORKDIR "/src/ZR.Admin.WebApi"
|
||||||
|
RUN dotnet build "ZR.Admin.WebApi.csproj" -c Release -o /app/build
|
||||||
|
|
||||||
# 复制发布文件到工作目录
|
FROM build AS publish
|
||||||
#COPY . app/
|
RUN dotnet publish "ZR.Admin.WebApi.csproj" -c Release -o /app/publish /p:UseAppHost=false
|
||||||
|
|
||||||
|
FROM base AS final
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
COPY --from=publish /app/publish .
|
||||||
#等价于 dotnet ZR.Admin.WebApi.dll,如果不指定启动端口默认在docker里面启动端口是80端口
|
ENTRYPOINT ["dotnet", "ZR.Admin.WebApi.dll"]
|
||||||
ENTRYPOINT ["dotnet", "ZR.Admin.WebApi.dll", "--server.urls","http://*:8888"]
|
|
||||||
|
|||||||
@ -4,6 +4,7 @@
|
|||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
<GenerateDocumentationFile>true</GenerateDocumentationFile>
|
<GenerateDocumentationFile>true</GenerateDocumentationFile>
|
||||||
|
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
|
||||||
<NoWarn>1701;1702;1591,8603,8602,8604,8600,8618</NoWarn>
|
<NoWarn>1701;1702;1591,8603,8602,8604,8600,8618</NoWarn>
|
||||||
@ -29,6 +30,9 @@
|
|||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<Content Include="..\.dockerignore">
|
||||||
|
<Link>.dockerignore</Link>
|
||||||
|
</Content>
|
||||||
<None Update="ip2region.db">
|
<None Update="ip2region.db">
|
||||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||||
</None>
|
</None>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user