From 41fd0a908b8d4ea2e9d2537674d6389e38e33aad Mon Sep 17 00:00:00 2001 From: walon Date: Thu, 25 Nov 2021 09:46:11 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90=E4=BC=98=E5=8C=96=E3=80=91=E4=BC=98?= =?UTF-8?q?=E5=8C=96Dockerfile=EF=BC=8C=E9=80=89=E7=94=A8cache=E5=8A=A0?= =?UTF-8?q?=E9=80=9F=E7=94=9F=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/.dockerignore | 4 ++ src/Luban.Client/Scripts/Dockerfile | 11 +++- src/Luban.ClientServer/Scripts/Dockerfile | 63 +++++++++++++++++++ .../Scripts/build_docker.bat | 2 + .../Scripts/build_docker.sh | 1 + .../Scripts/tag_and_push.bat | 3 + .../Scripts/tag_and_push.sh | 2 + src/Luban.Server/Scripts/Dockerfile | 34 +++++++--- 8 files changed, 109 insertions(+), 11 deletions(-) create mode 100644 src/Luban.ClientServer/Scripts/Dockerfile create mode 100644 src/Luban.ClientServer/Scripts/build_docker.bat create mode 100644 src/Luban.ClientServer/Scripts/build_docker.sh create mode 100644 src/Luban.ClientServer/Scripts/tag_and_push.bat create mode 100644 src/Luban.ClientServer/Scripts/tag_and_push.sh diff --git a/src/.dockerignore b/src/.dockerignore index 5967294..58649f0 100644 --- a/src/.dockerignore +++ b/src/.dockerignore @@ -1,2 +1,6 @@ **/bin/ **/obj/ +/lubanAssistant/ +/packages/ +/TestResults/ +LubanTools.sln diff --git a/src/Luban.Client/Scripts/Dockerfile b/src/Luban.Client/Scripts/Dockerfile index c5a5131..72a42e4 100644 --- a/src/Luban.Client/Scripts/Dockerfile +++ b/src/Luban.Client/Scripts/Dockerfile @@ -2,16 +2,23 @@ FROM mcr.microsoft.com/dotnet/sdk:6.0 as build WORKDIR /app/Luban.Common COPY Luban.Common/*.csproj ./ -COPY Luban.Common/Source ./Source COPY Luban.Common/.editorconfig . COPY nuget.config ./nuget.config WORKDIR /app/Luban.Client COPY Luban.Client/Luban.Client.csproj ./ COPY Luban.Client/.editorconfig . -COPY Luban.Client/Source ./Source 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 FROM mcr.microsoft.com/dotnet/runtime:6.0 AS runtime diff --git a/src/Luban.ClientServer/Scripts/Dockerfile b/src/Luban.ClientServer/Scripts/Dockerfile new file mode 100644 index 0000000..fd13ec2 --- /dev/null +++ b/src/Luban.ClientServer/Scripts/Dockerfile @@ -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"] \ No newline at end of file diff --git a/src/Luban.ClientServer/Scripts/build_docker.bat b/src/Luban.ClientServer/Scripts/build_docker.bat new file mode 100644 index 0000000..8bebffc --- /dev/null +++ b/src/Luban.ClientServer/Scripts/build_docker.bat @@ -0,0 +1,2 @@ +docker build -t luban-clientserver:latest -f Dockerfile ../.. +pause \ No newline at end of file diff --git a/src/Luban.ClientServer/Scripts/build_docker.sh b/src/Luban.ClientServer/Scripts/build_docker.sh new file mode 100644 index 0000000..f6f54d9 --- /dev/null +++ b/src/Luban.ClientServer/Scripts/build_docker.sh @@ -0,0 +1 @@ +docker build -t luban-clientserver:latest -f Dockerfile ../.. \ No newline at end of file diff --git a/src/Luban.ClientServer/Scripts/tag_and_push.bat b/src/Luban.ClientServer/Scripts/tag_and_push.bat new file mode 100644 index 0000000..6ef346c --- /dev/null +++ b/src/Luban.ClientServer/Scripts/tag_and_push.bat @@ -0,0 +1,3 @@ +docker tag luban-clientserver:latest focuscreativegames/luban-clientserver:latest +docker push focuscreativegames/luban-clientserver:latest +pause \ No newline at end of file diff --git a/src/Luban.ClientServer/Scripts/tag_and_push.sh b/src/Luban.ClientServer/Scripts/tag_and_push.sh new file mode 100644 index 0000000..75170c2 --- /dev/null +++ b/src/Luban.ClientServer/Scripts/tag_and_push.sh @@ -0,0 +1,2 @@ +docker tag luban-server:latest focuscreativegames/luban-server:latest +docker push focuscreativegames/luban-server:latest \ No newline at end of file diff --git a/src/Luban.Server/Scripts/Dockerfile b/src/Luban.Server/Scripts/Dockerfile index 5eac597..43e47c2 100644 --- a/src/Luban.Server/Scripts/Dockerfile +++ b/src/Luban.Server/Scripts/Dockerfile @@ -2,41 +2,57 @@ FROM mcr.microsoft.com/dotnet/sdk:6.0 as build WORKDIR /app/Luban.Common COPY Luban.Common/*.csproj ./ -COPY Luban.Common/Source ./Source -COPY Luban.Common/.editorconfig . -COPY nuget.config ./nuget.config +COPY Luban.Common/.editorconfig ./ WORKDIR /app/Luban.Server.Common COPY Luban.Server.Common/*.csproj ./ -COPY Luban.Server.Common/Source ./Source COPY nuget.config ./nuget.config WORKDIR /app/Luban.Job.Common COPY Luban.Job.Common/*.csproj ./ -COPY Luban.Job.Common/Source ./Source COPY nuget.config ./nuget.config WORKDIR /app/Luban.Job.Cfg COPY Luban.Job.Cfg/*.csproj ./ -COPY Luban.Job.Cfg/Source ./Source COPY nuget.config ./nuget.config WORKDIR /app/Luban.Job.Proto COPY Luban.Job.Proto/*.csproj ./ -COPY Luban.Job.Proto/Source ./Source COPY nuget.config ./nuget.config WORKDIR /app/Luban.Job.Db COPY Luban.Job.Db/*.csproj ./ -COPY Luban.Job.Db/Source ./Source COPY nuget.config ./nuget.config WORKDIR /app/Luban.Server COPY Luban.Server/Luban.Server.csproj ./ 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/Templates ./Templates -COPY nuget.config ./nuget.config RUN dotnet publish -c Release -o out