Version 2.1 #41
2
.gitignore
vendored
2
.gitignore
vendored
@ -265,4 +265,4 @@ src/MyWebLog/wwwroot/img/bit-badger
|
||||
src/MyWebLog/appsettings.Production.json
|
||||
|
||||
# SQLite database files
|
||||
src/MyWebLog/*.db*
|
||||
src/MyWebLog/data/*.db*
|
||||
|
@ -1,4 +1,4 @@
|
||||
FROM mcr.microsoft.com/dotnet/sdk:7.0-alpine AS build
|
||||
FROM mcr.microsoft.com/dotnet/sdk:8.0-alpine AS build
|
||||
WORKDIR /mwl
|
||||
COPY ./MyWebLog.sln ./
|
||||
COPY ./Directory.Build.props ./
|
||||
@ -9,7 +9,7 @@ RUN dotnet restore
|
||||
|
||||
COPY . ./
|
||||
WORKDIR /mwl/MyWebLog
|
||||
RUN dotnet publish -f net7.0 -c Release -r linux-x64 --no-self-contained -p:PublishSingleFile=false
|
||||
RUN dotnet publish -f net8.0 -c Release -r linux-x64 --no-self-contained -p:PublishSingleFile=false
|
||||
|
||||
FROM alpine AS theme
|
||||
RUN apk add --no-cache zip
|
||||
@ -19,12 +19,13 @@ 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-alpine as final
|
||||
FROM mcr.microsoft.com/dotnet/aspnet:8.0-alpine as final
|
||||
WORKDIR /app
|
||||
RUN apk add --no-cache icu-libs
|
||||
ENV DOTNET_SYSTEM_GLOBALIZATION_INVARIANT=false
|
||||
COPY --from=build /mwl/MyWebLog/bin/Release/net7.0/linux-x64/publish/ ./
|
||||
COPY --from=build /mwl/MyWebLog/bin/Release/net8.0/linux-x64/publish/ ./
|
||||
COPY --from=theme /themes/*.zip /app/
|
||||
RUN mkdir themes
|
||||
|
||||
EXPOSE 80
|
||||
CMD [ "dotnet", "/app/MyWebLog.dll" ]
|
||||
|
@ -482,7 +482,7 @@ module Theme =
|
||||
do! ThemeAssetCache.refreshTheme themeId data
|
||||
TemplateCache.invalidateTheme themeId
|
||||
// Save the .zip file
|
||||
use file = new FileStream($"{themeId}-theme.zip", FileMode.Create)
|
||||
use file = new FileStream($"./themes/{themeId}-theme.zip", FileMode.Create)
|
||||
do! themeFile.CopyToAsync file
|
||||
do! addMessage ctx
|
||||
{ UserMessage.Success with
|
||||
@ -517,7 +517,7 @@ module Theme =
|
||||
| _ ->
|
||||
match! data.Theme.Delete (ThemeId themeId) with
|
||||
| true ->
|
||||
let zippedTheme = $"{themeId}-theme.zip"
|
||||
let zippedTheme = $"./themes/{themeId}-theme.zip"
|
||||
if File.Exists zippedTheme then File.Delete zippedTheme
|
||||
do! addMessage ctx { UserMessage.Success with Message = $"Theme ID {themeId} deleted successfully" }
|
||||
return! all next ctx
|
||||
|
@ -98,7 +98,7 @@ module DataImplementation =
|
||||
log.LogInformation $"Using PostgreSQL database {conn.Database}"
|
||||
PostgresData(log, Json.configure (JsonSerializer.CreateDefault()))
|
||||
else
|
||||
createSQLite "Data Source=./myweblog.db;Cache=Shared"
|
||||
createSQLite "Data Source=./data/myweblog.db;Cache=Shared"
|
||||
|
||||
|
||||
open System.Threading.Tasks
|
||||
@ -176,7 +176,7 @@ let main args =
|
||||
let _ = builder.Services.AddScoped<SqliteConnection>(fun sp -> Sqlite.Configuration.dbConn ())
|
||||
let _ = builder.Services.AddScoped<IData, SQLiteData>()
|
||||
// Use SQLite for caching as well
|
||||
let cachePath = defaultArg (Option.ofObj (cfg.GetConnectionString "SQLiteCachePath")) "./session.db"
|
||||
let cachePath = defaultArg (Option.ofObj (cfg.GetConnectionString "SQLiteCachePath")) "./data/session.db"
|
||||
let _ = builder.Services.AddSqliteCache(fun o -> o.CachePath <- cachePath)
|
||||
()
|
||||
| :? PostgresData as postgres ->
|
||||
@ -214,8 +214,11 @@ let main args =
|
||||
printfn $"""Unrecognized command "{it}" - valid commands are:"""
|
||||
showHelp ()
|
||||
| None -> task {
|
||||
// Load all themes in the application directory
|
||||
for themeFile in Directory.EnumerateFiles(".", "*-theme.zip") do
|
||||
// Load admin and default themes, and all themes in the /themes directory
|
||||
do! Maintenance.loadTheme [| ""; "./admin-theme.zip" |] app.Services
|
||||
do! Maintenance.loadTheme [| ""; "./default-theme.zip" |] app.Services
|
||||
if Directory.Exists "./themes" then
|
||||
for themeFile in Directory.EnumerateFiles("./themes", "*-theme.zip") do
|
||||
do! Maintenance.loadTheme [| ""; themeFile |] app.Services
|
||||
|
||||
let _ = app.UseForwardedHeaders()
|
||||
|
@ -1,4 +1,4 @@
|
||||
FROM mcr.microsoft.com/dotnet/sdk:7.0 AS build
|
||||
FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
|
||||
WORKDIR /mwl
|
||||
COPY ./MyWebLog.sln ./
|
||||
COPY ./Directory.Build.props ./
|
||||
@ -9,7 +9,7 @@ RUN dotnet restore
|
||||
|
||||
COPY . ./
|
||||
WORKDIR /mwl/MyWebLog
|
||||
RUN dotnet publish -f net7.0 -c Release -r linux-x64
|
||||
RUN dotnet publish -f net8.0 -c Release -r linux-x64
|
||||
|
||||
FROM alpine AS theme
|
||||
RUN apk add --no-cache zip
|
||||
@ -19,10 +19,11 @@ 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
|
||||
FROM mcr.microsoft.com/dotnet/aspnet:8.0 as final
|
||||
WORKDIR /app
|
||||
COPY --from=build /mwl/MyWebLog/bin/Release/net7.0/linux-x64/publish/ ./
|
||||
COPY --from=build /mwl/MyWebLog/bin/Release/net8.0/linux-x64/publish/ ./
|
||||
COPY --from=theme /themes/*.zip /app/
|
||||
RUN mkdir data themes
|
||||
|
||||
EXPOSE 80
|
||||
CMD [ "/app/MyWebLog" ]
|
||||
|
Loading…
Reference in New Issue
Block a user