Compare commits

...

2 Commits

Author SHA1 Message Date
8066478447
Simplify copying csproj files in Docker build
All checks were successful
Docker Image CI / build (push) Successful in 1m41s
2024-07-11 21:46:55 +01:00
4c62cded56
Enable X-Forwarded-* headers using env var instead of code 2024-07-11 21:45:04 +01:00
2 changed files with 4 additions and 11 deletions

View File

@ -1,3 +1,5 @@
# syntax=docker/dockerfile:1.7-labs
FROM mcr.microsoft.com/dotnet/sdk:8.0-alpine AS build1
WORKDIR /src
@ -14,8 +16,7 @@ WORKDIR /src
COPY ./Groceries.sln ./
COPY ./Directory.Build.props ./
COPY */*.csproj ./
RUN for file in $(ls *.csproj); do mkdir -p ${file%.*} && mv $file ${file%.*}; done
COPY --parents */*.csproj .
RUN dotnet restore
COPY . ./
@ -30,6 +31,7 @@ COPY --from=build2 /src/Groceries/config.ini /config/
RUN apk add --no-cache icu-libs tzdata
ENV ASPNETCORE_FORWARDEDHEADERS_ENABLED=true
ENV ASPNETCORE_HTTP_PORTS=80
ENV DOTNET_ENABLEDIAGNOSTICS=0
ENV DOTNET_SYSTEM_GLOBALIZATION_INVARIANT=false

View File

@ -1,7 +1,6 @@
using DbUp;
using Groceries.Data;
using Microsoft.AspNetCore.DataProtection;
using Microsoft.AspNetCore.HttpOverrides;
using Microsoft.EntityFrameworkCore;
var builder = WebApplication.CreateBuilder(args);
@ -29,13 +28,6 @@ if (!dbUpgradeResult.Successful)
return -1;
}
builder.Services.Configure<ForwardedHeadersOptions>(options =>
{
options.ForwardedHeaders = ForwardedHeaders.All;
options.KnownNetworks.Clear();
options.KnownProxies.Clear();
});
var dataProtection = builder.Services.AddDataProtection();
if (env.IsProduction())
{
@ -59,7 +51,6 @@ builder.Services.AddDbContextPool<AppDbContext>(options => options
var app = builder.Build();
app.UseForwardedHeaders();
app.UseStaticFiles();
app.UseRouting();
app.UseSession();