From 7d8f5e62acddde72ec72e31b8a538f0a3a9ef6df Mon Sep 17 00:00:00 2001 From: Tudor Stanciu Date: Fri, 25 Dec 2020 01:17:36 +0200 Subject: [PATCH] Added docker support --- .dockerignore | 25 ++++++++++++++ IdentityServer.Api/Dockerfile | 34 ++++++++++++++++++++ IdentityServer.Api/IdentityServer.Api.csproj | 1 + IdentityServer.sln | 3 +- 4 files changed, 62 insertions(+), 1 deletion(-) create mode 100644 .dockerignore create mode 100644 IdentityServer.Api/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/IdentityServer.Api/Dockerfile b/IdentityServer.Api/Dockerfile new file mode 100644 index 0000000..8ed0f5a --- /dev/null +++ b/IdentityServer.Api/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 ["IdentityServer.Api/IdentityServer.Api.csproj", "IdentityServer.Api/"] +COPY ["IdentityServer.Application/IdentityServer.Application.csproj", "IdentityServer.Application/"] +COPY ["IdentityServer.Domain/IdentityServer.Domain.csproj", "IdentityServer.Domain/"] +COPY ["IdentityServer.PublishedLanguage/IdentityServer.PublishedLanguage.csproj", "IdentityServer.PublishedLanguage/"] +COPY ["IdentityServer.Domain.Data/IdentityServer.Domain.Data.csproj", "IdentityServer.Domain.Data/"] +RUN dotnet restore "IdentityServer.Api/IdentityServer.Api.csproj" +COPY . . +WORKDIR "/src/IdentityServer.Api" +RUN dotnet build "IdentityServer.Api.csproj" -c Release -o /app/build + +FROM build AS publish +RUN dotnet publish "IdentityServer.Api.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", "IdentityServer.Api.dll"] \ No newline at end of file diff --git a/IdentityServer.Api/IdentityServer.Api.csproj b/IdentityServer.Api/IdentityServer.Api.csproj index be89171..f58b3c2 100644 --- a/IdentityServer.Api/IdentityServer.Api.csproj +++ b/IdentityServer.Api/IdentityServer.Api.csproj @@ -2,6 +2,7 @@ netcoreapp3.1 + Linux diff --git a/IdentityServer.sln b/IdentityServer.sln index 1d86b46..3960498 100644 --- a/IdentityServer.sln +++ b/IdentityServer.sln @@ -9,6 +9,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "IdentityServer.Api", "Ident EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{0B8B6E9B-0200-47EC-91D9-BEDF4BFC248F}" ProjectSection(SolutionItems) = preProject + .dockerignore = .dockerignore .gitattributes = .gitattributes .gitignore = .gitignore dependencies.props = dependencies.props @@ -26,7 +27,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "IdentityServer.Domain.Data" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "IdentityServer.PublishedLanguage", "IdentityServer.PublishedLanguage\IdentityServer.PublishedLanguage.csproj", "{67B4D1FF-D02E-4DA6-9FB8-F71667360448}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "IdentityServer.Wrapper", "IdentityServer.Wrapper\IdentityServer.Wrapper.csproj", "{F6FEC33B-C79E-4484-B356-9C7F1A5E5D95}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "IdentityServer.Wrapper", "IdentityServer.Wrapper\IdentityServer.Wrapper.csproj", "{F6FEC33B-C79E-4484-B356-9C7F1A5E5D95}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution