From 3e1fc51b3c2ee83a86cd3cca725cc7917d7273db Mon Sep 17 00:00:00 2001 From: "Fritz (Fredrick Seitz)" Date: Sat, 21 Sep 2024 14:01:06 -0400 Subject: [PATCH] fix: use distorless docker container --- Dockerfile | 10 ++++------ src/Bulwark.Auth/Program.cs | 6 +++--- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/Dockerfile b/Dockerfile index 66682c5..d4fff37 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,10 +1,10 @@ -FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS base +FROM mcr.microsoft.com/dotnet/sdk:8.0-jammy AS base USER $APP_UID WORKDIR /app EXPOSE 8080 EXPOSE 8081 -FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build +FROM mcr.microsoft.com/dotnet/sdk:8.0-jammy AS build ARG BUILD_CONFIGURATION=Release WORKDIR /src COPY ["src/Bulwark.Auth/Bulwark.Auth.csproj", "src/Bulwark.Auth/"] @@ -19,9 +19,7 @@ FROM build AS publish ARG BUILD_CONFIGURATION=Release RUN dotnet publish "Bulwark.Auth.csproj" -c $BUILD_CONFIGURATION -o /app/publish /p:UseAppHost=false -FROM base AS final +FROM mcr.microsoft.com/dotnet/aspnet:8.0-jammy-chiseled AS final WORKDIR /app COPY --from=publish /app/publish . -ENTRYPOINT ["dotnet", "Bulwark.Auth.dll"] - - +ENTRYPOINT ["dotnet", "Bulwark.Auth.dll"] \ No newline at end of file diff --git a/src/Bulwark.Auth/Program.cs b/src/Bulwark.Auth/Program.cs index 530ef7b..e867ee4 100644 --- a/src/Bulwark.Auth/Program.cs +++ b/src/Bulwark.Auth/Program.cs @@ -18,7 +18,7 @@ using MongoDB.Driver; using Microsoft.Extensions.Hosting; using Microsoft.Extensions.Logging; -//trigger build: update docker build +//trigger build: update docker build with distroless var applicationBuilder = WebApplication.CreateBuilder(args); DotEnv.Load(options: new DotEnvOptions(overwriteExistingVars: false)); //AppConfig must be initialized after DotEnv.Load for environment variables to be available @@ -109,7 +109,7 @@ socialValidators.Add(googleValidator); } -if (!string.IsNullOrEmpty(appConfig.MicrosoftClientId) && +if (!string.IsNullOrEmpty(appConfig.MicrosoftClientId) && !string.IsNullOrEmpty(appConfig.MicrosoftTenantId)) { var microSoftValidator = new MicrosoftValidator(appConfig.MicrosoftClientId, appConfig.MicrosoftTenantId); @@ -163,4 +163,4 @@ webApplication.UseRouting(); webApplication.MapControllers(); webApplication.Run(); -//end of config +//end of config \ No newline at end of file