【优化】优化Dockerfile,选用cache加速生成

main
walon 2021-11-25 09:46:11 +08:00
parent 3a021f74a8
commit 41fd0a908b
8 changed files with 109 additions and 11 deletions

View File

@ -1,2 +1,6 @@
**/bin/ **/bin/
**/obj/ **/obj/
/lubanAssistant/
/packages/
/TestResults/
LubanTools.sln

View File

@ -2,16 +2,23 @@ FROM mcr.microsoft.com/dotnet/sdk:6.0 as build
WORKDIR /app/Luban.Common WORKDIR /app/Luban.Common
COPY Luban.Common/*.csproj ./ COPY Luban.Common/*.csproj ./
COPY Luban.Common/Source ./Source
COPY Luban.Common/.editorconfig . COPY Luban.Common/.editorconfig .
COPY nuget.config ./nuget.config COPY nuget.config ./nuget.config
WORKDIR /app/Luban.Client WORKDIR /app/Luban.Client
COPY Luban.Client/Luban.Client.csproj ./ COPY Luban.Client/Luban.Client.csproj ./
COPY Luban.Client/.editorconfig . COPY Luban.Client/.editorconfig .
COPY Luban.Client/Source ./Source
COPY nuget.config ./nuget.config COPY nuget.config ./nuget.config
RUN dotnet restore
WORKDIR /app/Luban.Common
COPY Luban.Common/Source ./Source
WORKDIR /app/Luban.Client
COPY Luban.Client/Source ./Source
RUN dotnet publish -c Release -o out RUN dotnet publish -c Release -o out
FROM mcr.microsoft.com/dotnet/runtime:6.0 AS runtime FROM mcr.microsoft.com/dotnet/runtime:6.0 AS runtime

View File

@ -0,0 +1,63 @@
FROM mcr.microsoft.com/dotnet/sdk:6.0 as build
WORKDIR /app/Luban.Common
COPY Luban.Common/*.csproj ./
COPY Luban.Common/.editorconfig ./
WORKDIR /app/Luban.ClientServer.Common
COPY Luban.ClientServer.Common/*.csproj ./
COPY nuget.config ./nuget.config
WORKDIR /app/Luban.Job.Common
COPY Luban.Job.Common/*.csproj ./
COPY nuget.config ./nuget.config
WORKDIR /app/Luban.Job.Cfg
COPY Luban.Job.Cfg/*.csproj ./
COPY nuget.config ./nuget.config
WORKDIR /app/Luban.Job.Proto
COPY Luban.Job.Proto/*.csproj ./
COPY nuget.config ./nuget.config
WORKDIR /app/Luban.Job.Db
COPY Luban.Job.Db/*.csproj ./
COPY nuget.config ./nuget.config
WORKDIR /app/Luban.ClientServer
COPY Luban.ClientServer/Luban.ClientServer.csproj ./
COPY Luban.ClientServer/.editorconfig .
COPY nuget.config ./nuget.config
RUN dotnet restore
WORKDIR /app/Luban.Common
COPY Luban.Common/Source ./Source
WORKDIR /app/Luban.ClientServer.Common
COPY Luban.ClientServer.Common/Source ./Source
WORKDIR /app/Luban.Job.Common
COPY Luban.Job.Common/Source ./Source
WORKDIR /app/Luban.Job.Cfg
COPY Luban.Job.Cfg/Source ./Source
WORKDIR /app/Luban.Job.Proto
COPY Luban.Job.Proto/Source ./Source
WORKDIR /app/Luban.Job.Db
COPY Luban.Job.Db/Source ./Source
WORKDIR /app/Luban.ClientServer
COPY Luban.ClientServer/Source ./Source
COPY Luban.Server/Templates ./Templates
RUN dotnet publish -c Release -o out
FROM mcr.microsoft.com/dotnet/runtime:6.0 AS runtime
WORKDIR /app
COPY --from=build /app/Luban.ClientServer/out ./
EXPOSE 8899/tcp
ENTRYPOINT ["/app/Luban.ClientServer", "-p", "8899"]

View File

@ -0,0 +1,2 @@
docker build -t luban-clientserver:latest -f Dockerfile ../..
pause

View File

@ -0,0 +1 @@
docker build -t luban-clientserver:latest -f Dockerfile ../..

View File

@ -0,0 +1,3 @@
docker tag luban-clientserver:latest focuscreativegames/luban-clientserver:latest
docker push focuscreativegames/luban-clientserver:latest
pause

View File

@ -0,0 +1,2 @@
docker tag luban-server:latest focuscreativegames/luban-server:latest
docker push focuscreativegames/luban-server:latest

View File

@ -2,41 +2,57 @@ FROM mcr.microsoft.com/dotnet/sdk:6.0 as build
WORKDIR /app/Luban.Common WORKDIR /app/Luban.Common
COPY Luban.Common/*.csproj ./ COPY Luban.Common/*.csproj ./
COPY Luban.Common/Source ./Source COPY Luban.Common/.editorconfig ./
COPY Luban.Common/.editorconfig .
COPY nuget.config ./nuget.config
WORKDIR /app/Luban.Server.Common WORKDIR /app/Luban.Server.Common
COPY Luban.Server.Common/*.csproj ./ COPY Luban.Server.Common/*.csproj ./
COPY Luban.Server.Common/Source ./Source
COPY nuget.config ./nuget.config COPY nuget.config ./nuget.config
WORKDIR /app/Luban.Job.Common WORKDIR /app/Luban.Job.Common
COPY Luban.Job.Common/*.csproj ./ COPY Luban.Job.Common/*.csproj ./
COPY Luban.Job.Common/Source ./Source
COPY nuget.config ./nuget.config COPY nuget.config ./nuget.config
WORKDIR /app/Luban.Job.Cfg WORKDIR /app/Luban.Job.Cfg
COPY Luban.Job.Cfg/*.csproj ./ COPY Luban.Job.Cfg/*.csproj ./
COPY Luban.Job.Cfg/Source ./Source
COPY nuget.config ./nuget.config COPY nuget.config ./nuget.config
WORKDIR /app/Luban.Job.Proto WORKDIR /app/Luban.Job.Proto
COPY Luban.Job.Proto/*.csproj ./ COPY Luban.Job.Proto/*.csproj ./
COPY Luban.Job.Proto/Source ./Source
COPY nuget.config ./nuget.config COPY nuget.config ./nuget.config
WORKDIR /app/Luban.Job.Db WORKDIR /app/Luban.Job.Db
COPY Luban.Job.Db/*.csproj ./ COPY Luban.Job.Db/*.csproj ./
COPY Luban.Job.Db/Source ./Source
COPY nuget.config ./nuget.config COPY nuget.config ./nuget.config
WORKDIR /app/Luban.Server WORKDIR /app/Luban.Server
COPY Luban.Server/Luban.Server.csproj ./ COPY Luban.Server/Luban.Server.csproj ./
COPY Luban.Server/.editorconfig . COPY Luban.Server/.editorconfig .
COPY nuget.config ./nuget.config
RUN dotnet restore
WORKDIR /app/Luban.Common
COPY Luban.Common/Source ./Source
WORKDIR /app/Luban.Server.Common
COPY Luban.Server.Common/Source ./Source
WORKDIR /app/Luban.Job.Common
COPY Luban.Job.Common/Source ./Source
WORKDIR /app/Luban.Job.Cfg
COPY Luban.Job.Cfg/Source ./Source
WORKDIR /app/Luban.Job.Proto
COPY Luban.Job.Proto/Source ./Source
WORKDIR /app/Luban.Job.Db
COPY Luban.Job.Db/Source ./Source
WORKDIR /app/Luban.Server
COPY Luban.Server/Source ./Source COPY Luban.Server/Source ./Source
COPY Luban.Server/Templates ./Templates COPY Luban.Server/Templates ./Templates
COPY nuget.config ./nuget.config
RUN dotnet publish -c Release -o out RUN dotnet publish -c Release -o out