From f6d55d1b711204af9503ca5e33a3b3ba62ddf15a Mon Sep 17 00:00:00 2001 From: Tudor Stanciu Date: Sat, 26 Dec 2020 01:03:16 +0200 Subject: [PATCH] Added docker support for ressurector agent --- .dockerignore | 25 ++++++++++++++ NetworkResurrector.Agent/Dockerfile | 34 +++++++++++++++++++ .../NetworkResurrector.Agent.csproj | 1 + NetworkResurrector.sln | 9 ++--- 4 files changed, 65 insertions(+), 4 deletions(-) create mode 100644 .dockerignore create mode 100644 NetworkResurrector.Agent/Dockerfile diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..3729ff0 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,25 @@ +**/.classpath +**/.dockerignore +**/.env +**/.git +**/.gitignore +**/.project +**/.settings +**/.toolstarget +**/.vs +**/.vscode +**/*.*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 \ No newline at end of file diff --git a/NetworkResurrector.Agent/Dockerfile b/NetworkResurrector.Agent/Dockerfile new file mode 100644 index 0000000..c532790 --- /dev/null +++ b/NetworkResurrector.Agent/Dockerfile @@ -0,0 +1,34 @@ +#See https://aka.ms/containerfastmode to understand how Visual Studio uses this Dockerfile to build your images for faster debugging. + +FROM mcr.microsoft.com/dotnet/core/aspnet:3.1-buster-slim AS base +WORKDIR /app +EXPOSE 80 + +FROM mcr.microsoft.com/dotnet/core/sdk:3.1-buster AS build +WORKDIR /src +COPY dependencies.props . +COPY Directory.Build.props . +COPY NuGet.config . +COPY ["NetworkResurrector.Agent/NetworkResurrector.Agent.csproj", "NetworkResurrector.Agent/"] +COPY ["NetworkResurrector.Agent.Application/NetworkResurrector.Agent.Application.csproj", "NetworkResurrector.Agent.Application/"] +COPY ["NetworkResurrector.Agent.Domain/NetworkResurrector.Agent.Domain.csproj", "NetworkResurrector.Agent.Domain/"] +COPY ["NetworkResurrector.Agent.Domain.Data/NetworkResurrector.Agent.Domain.Data.csproj", "NetworkResurrector.Agent.Domain.Data/"] +RUN dotnet restore "NetworkResurrector.Agent/NetworkResurrector.Agent.csproj" +COPY . . +WORKDIR "/src/NetworkResurrector.Agent" +RUN dotnet build "NetworkResurrector.Agent.csproj" -c Release -o /app/build + +FROM build AS publish +RUN dotnet publish "NetworkResurrector.Agent.csproj" -c Release -o /app/publish + +FROM base AS final +WORKDIR /app +COPY --from=publish /app/publish . + +ENV urls="http://*:80" +ENV ConnectionStrings__DatabaseConnection="***REMOVED***" + +#Workaround to lower the TLS level in container for old sql server version +RUN sed -i 's/TLSv1.2/TLSv1.0/g' /etc/ssl/openssl.cnf + +ENTRYPOINT ["dotnet", "NetworkResurrector.Agent.dll", "--console"] \ No newline at end of file diff --git a/NetworkResurrector.Agent/NetworkResurrector.Agent.csproj b/NetworkResurrector.Agent/NetworkResurrector.Agent.csproj index 20ada41..46a7ae4 100644 --- a/NetworkResurrector.Agent/NetworkResurrector.Agent.csproj +++ b/NetworkResurrector.Agent/NetworkResurrector.Agent.csproj @@ -2,6 +2,7 @@ netcoreapp3.1 + Linux diff --git a/NetworkResurrector.sln b/NetworkResurrector.sln index 999e3dc..4026593 100644 --- a/NetworkResurrector.sln +++ b/NetworkResurrector.sln @@ -7,6 +7,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NetworkResurrector.Api", "N EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{FDDE879C-E0A3-4BF1-945F-7FEA324C8EBA}" ProjectSection(SolutionItems) = preProject + .dockerignore = .dockerignore .gitattributes = .gitattributes .gitignore = .gitignore dependencies.props = dependencies.props @@ -32,13 +33,13 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "api", "api", "{6889D39C-D8D EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "agent", "agent", "{43C78941-52E6-4AB8-9170-CC7C006E4784}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NetworkResurrector.Agent", "NetworkResurrector.Agent\NetworkResurrector.Agent.csproj", "{E10CEE53-8167-446F-BFF3-B80725BB6C90}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NetworkResurrector.Agent", "NetworkResurrector.Agent\NetworkResurrector.Agent.csproj", "{E10CEE53-8167-446F-BFF3-B80725BB6C90}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NetworkResurrector.Agent.Application", "NetworkResurrector.Agent.Application\NetworkResurrector.Agent.Application.csproj", "{EE31B126-12EC-46B3-8FB4-AD5BCF14C029}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NetworkResurrector.Agent.Application", "NetworkResurrector.Agent.Application\NetworkResurrector.Agent.Application.csproj", "{EE31B126-12EC-46B3-8FB4-AD5BCF14C029}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NetworkResurrector.Agent.Domain", "NetworkResurrector.Agent.Domain\NetworkResurrector.Agent.Domain.csproj", "{885D5625-028A-4B35-8C89-7EF718BC6E34}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NetworkResurrector.Agent.Domain", "NetworkResurrector.Agent.Domain\NetworkResurrector.Agent.Domain.csproj", "{885D5625-028A-4B35-8C89-7EF718BC6E34}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NetworkResurrector.Agent.Domain.Data", "NetworkResurrector.Agent.Domain.Data\NetworkResurrector.Agent.Domain.Data.csproj", "{509767A7-D11C-4143-8D45-01E62DFC2C74}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NetworkResurrector.Agent.Domain.Data", "NetworkResurrector.Agent.Domain.Data\NetworkResurrector.Agent.Domain.Data.csproj", "{509767A7-D11C-4143-8D45-01E62DFC2C74}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution