From d6ab6fa4026c9b5d39cb8ba9669359937cd29658 Mon Sep 17 00:00:00 2001 From: James Tombleson Date: Thu, 15 Jun 2023 21:50:36 -0700 Subject: [PATCH] Moving Dockerfile to the root --- .dockerignore | 3 +++ Dockerfile | 20 ++++++++++++++++++++ Newsbot.Portal.Blazor.Server/Global.cs | 2 +- 3 files changed, 24 insertions(+), 1 deletion(-) create mode 100644 .dockerignore create mode 100644 Dockerfile diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..07c6bb4 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,3 @@ +appsettings.json +**/bin/ +**/obj/ \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..2320354 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,20 @@ +FROM mcr.microsoft.com/dotnet/aspnet:7.0 AS base +WORKDIR /app +EXPOSE 80 +EXPOSE 443 + +FROM mcr.microsoft.com/dotnet/sdk:7.0 AS build +WORKDIR /src +COPY ["Newsbot.Portal.Blazor.Server/Newsbot.Portal.Blazor.Server.csproj", "Newsbot.Portal.Blazor.Server/"] +RUN dotnet restore "Newsbot.Portal.Blazor.Server/Newsbot.Portal.Blazor.Server.csproj" +COPY . . +WORKDIR "/src/Newsbot.Portal.Blazor.Server" +RUN dotnet build "Newsbot.Portal.Blazor.Server.csproj" -c Release -o /app/build + +FROM build AS publish +RUN dotnet publish "Newsbot.Portal.Blazor.Server.csproj" -c Release -o /app/publish /p:UseAppHost=false + +FROM base AS final +WORKDIR /app +COPY --from=publish /app/publish . +ENTRYPOINT ["dotnet", "Newsbot.Portal.Blazor.Server.dll"] diff --git a/Newsbot.Portal.Blazor.Server/Global.cs b/Newsbot.Portal.Blazor.Server/Global.cs index 0eda7bd..894e61a 100644 --- a/Newsbot.Portal.Blazor.Server/Global.cs +++ b/Newsbot.Portal.Blazor.Server/Global.cs @@ -2,6 +2,6 @@ namespace Newsbot.Portal.Blazor.Server; public static class Global { - public static HttpClient HttpClient { get; set; } + public static HttpClient? HttpClient { get; set; } public static string? DefaultInstanceUri { get; set; } } \ No newline at end of file