diff --git a/src/.dockerignore b/src/.dockerignore new file mode 100644 index 0000000..f181d71 --- /dev/null +++ b/src/.dockerignore @@ -0,0 +1,2 @@ +**/bin +**/obj diff --git a/src/Directory.Build.props b/src/Directory.Build.props index 5529e72..e376d97 100644 --- a/src/Directory.Build.props +++ b/src/Directory.Build.props @@ -2,8 +2,8 @@ net6.0;net7.0 embedded - 2.0.0.0 - 2.0.0.0 - 2.0.0 + 2.1.0.0 + 2.1.0.0 + 2.1.0 diff --git a/src/Dockerfile b/src/Dockerfile new file mode 100644 index 0000000..cf71ceb --- /dev/null +++ b/src/Dockerfile @@ -0,0 +1,28 @@ +FROM mcr.microsoft.com/dotnet/sdk:7.0 AS build +WORKDIR /mwl +COPY ./MyWebLog.sln ./ +COPY ./Directory.Build.props ./ +COPY ./MyWebLog/MyWebLog.fsproj ./MyWebLog/ +COPY ./MyWebLog.Data/MyWebLog.Data.fsproj ./MyWebLog.Data/ +COPY ./MyWebLog.Domain/MyWebLog.Domain.fsproj ./MyWebLog.Domain/ +RUN dotnet restore + +COPY . ./ +WORKDIR /mwl/MyWebLog +RUN dotnet publish -f net7.0 -c Release -r linux-x64 + +FROM alpine AS theme +RUN apk add --no-cache zip +WORKDIR /themes +COPY ./default-theme ./default-theme/ +RUN zip default-theme.zip ./default-theme/* +COPY ./admin-theme ./admin-theme/ +RUN zip admin-theme.zip ./admin-theme/* + +FROM mcr.microsoft.com/dotnet/aspnet:7.0 as final +WORKDIR /app +COPY --from=build /mwl/MyWebLog/bin/Release/net7.0/linux-x64/publish/ ./ +COPY --from=theme /themes/*.zip /app/ + +EXPOSE 80 +CMD [ "/app/MyWebLog" ] diff --git a/src/MyWebLog.Data/SQLiteData.fs b/src/MyWebLog.Data/SQLiteData.fs index 873945c..6133eb1 100644 --- a/src/MyWebLog.Data/SQLiteData.fs +++ b/src/MyWebLog.Data/SQLiteData.fs @@ -210,7 +210,7 @@ type SQLiteData (conn : SqliteConnection, log : ILogger, ser : JsonS // Database version table if needsTable "db_version" then "CREATE TABLE db_version (id TEXT PRIMARY KEY); - INSERT INTO db_version VALUES ('v2-rc1')" + INSERT INTO db_version VALUES ('v2')" } |> Seq.map (fun sql -> log.LogInformation $"Creating {(sql.Split ' ')[2]} table..." diff --git a/src/MyWebLog/Program.fs b/src/MyWebLog/Program.fs index 1437985..7b0c3ca 100644 --- a/src/MyWebLog/Program.fs +++ b/src/MyWebLog/Program.fs @@ -203,8 +203,9 @@ let rec main args = let _ = app.UseForwardedHeaders () - let domainCfg = app.Services.GetRequiredService().GetSection "CanonicalDomains" - if domainCfg.AsEnumerable().Count () > 0 then app.UseCanonicalDomains () |> ignore + (app.Services.GetRequiredService().GetSection "CanonicalDomains").Value + |> (isNull >> not) + |> function true -> app.UseCanonicalDomains () |> ignore | false -> () let _ = app.UseCookiePolicy (CookiePolicyOptions (MinimumSameSitePolicy = SameSiteMode.Strict)) let _ = app.UseMiddleware ()