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
|
src/MyWebLog/appsettings.Production.json
|
||||||
|
|
||||||
# SQLite database files
|
# 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
|
WORKDIR /mwl
|
||||||
COPY ./MyWebLog.sln ./
|
COPY ./MyWebLog.sln ./
|
||||||
COPY ./Directory.Build.props ./
|
COPY ./Directory.Build.props ./
|
||||||
@ -9,7 +9,7 @@ RUN dotnet restore
|
|||||||
|
|
||||||
COPY . ./
|
COPY . ./
|
||||||
WORKDIR /mwl/MyWebLog
|
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
|
FROM alpine AS theme
|
||||||
RUN apk add --no-cache zip
|
RUN apk add --no-cache zip
|
||||||
@ -19,12 +19,13 @@ RUN zip default-theme.zip ./default-theme/*
|
|||||||
COPY ./admin-theme ./admin-theme/
|
COPY ./admin-theme ./admin-theme/
|
||||||
RUN zip admin-theme.zip ./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
|
WORKDIR /app
|
||||||
RUN apk add --no-cache icu-libs
|
RUN apk add --no-cache icu-libs
|
||||||
ENV DOTNET_SYSTEM_GLOBALIZATION_INVARIANT=false
|
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/
|
COPY --from=theme /themes/*.zip /app/
|
||||||
|
RUN mkdir themes
|
||||||
|
|
||||||
EXPOSE 80
|
EXPOSE 80
|
||||||
CMD [ "dotnet", "/app/MyWebLog.dll" ]
|
CMD [ "dotnet", "/app/MyWebLog.dll" ]
|
||||||
|
@ -482,7 +482,7 @@ module Theme =
|
|||||||
do! ThemeAssetCache.refreshTheme themeId data
|
do! ThemeAssetCache.refreshTheme themeId data
|
||||||
TemplateCache.invalidateTheme themeId
|
TemplateCache.invalidateTheme themeId
|
||||||
// Save the .zip file
|
// 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! themeFile.CopyToAsync file
|
||||||
do! addMessage ctx
|
do! addMessage ctx
|
||||||
{ UserMessage.Success with
|
{ UserMessage.Success with
|
||||||
@ -517,7 +517,7 @@ module Theme =
|
|||||||
| _ ->
|
| _ ->
|
||||||
match! data.Theme.Delete (ThemeId themeId) with
|
match! data.Theme.Delete (ThemeId themeId) with
|
||||||
| true ->
|
| true ->
|
||||||
let zippedTheme = $"{themeId}-theme.zip"
|
let zippedTheme = $"./themes/{themeId}-theme.zip"
|
||||||
if File.Exists zippedTheme then File.Delete zippedTheme
|
if File.Exists zippedTheme then File.Delete zippedTheme
|
||||||
do! addMessage ctx { UserMessage.Success with Message = $"Theme ID {themeId} deleted successfully" }
|
do! addMessage ctx { UserMessage.Success with Message = $"Theme ID {themeId} deleted successfully" }
|
||||||
return! all next ctx
|
return! all next ctx
|
||||||
|
@ -98,7 +98,7 @@ module DataImplementation =
|
|||||||
log.LogInformation $"Using PostgreSQL database {conn.Database}"
|
log.LogInformation $"Using PostgreSQL database {conn.Database}"
|
||||||
PostgresData(log, Json.configure (JsonSerializer.CreateDefault()))
|
PostgresData(log, Json.configure (JsonSerializer.CreateDefault()))
|
||||||
else
|
else
|
||||||
createSQLite "Data Source=./myweblog.db;Cache=Shared"
|
createSQLite "Data Source=./data/myweblog.db;Cache=Shared"
|
||||||
|
|
||||||
|
|
||||||
open System.Threading.Tasks
|
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<SqliteConnection>(fun sp -> Sqlite.Configuration.dbConn ())
|
||||||
let _ = builder.Services.AddScoped<IData, SQLiteData>()
|
let _ = builder.Services.AddScoped<IData, SQLiteData>()
|
||||||
// Use SQLite for caching as well
|
// 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)
|
let _ = builder.Services.AddSqliteCache(fun o -> o.CachePath <- cachePath)
|
||||||
()
|
()
|
||||||
| :? PostgresData as postgres ->
|
| :? PostgresData as postgres ->
|
||||||
@ -214,8 +214,11 @@ let main args =
|
|||||||
printfn $"""Unrecognized command "{it}" - valid commands are:"""
|
printfn $"""Unrecognized command "{it}" - valid commands are:"""
|
||||||
showHelp ()
|
showHelp ()
|
||||||
| None -> task {
|
| None -> task {
|
||||||
// Load all themes in the application directory
|
// Load admin and default themes, and all themes in the /themes directory
|
||||||
for themeFile in Directory.EnumerateFiles(".", "*-theme.zip") do
|
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
|
do! Maintenance.loadTheme [| ""; themeFile |] app.Services
|
||||||
|
|
||||||
let _ = app.UseForwardedHeaders()
|
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
|
WORKDIR /mwl
|
||||||
COPY ./MyWebLog.sln ./
|
COPY ./MyWebLog.sln ./
|
||||||
COPY ./Directory.Build.props ./
|
COPY ./Directory.Build.props ./
|
||||||
@ -9,7 +9,7 @@ RUN dotnet restore
|
|||||||
|
|
||||||
COPY . ./
|
COPY . ./
|
||||||
WORKDIR /mwl/MyWebLog
|
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
|
FROM alpine AS theme
|
||||||
RUN apk add --no-cache zip
|
RUN apk add --no-cache zip
|
||||||
@ -19,10 +19,11 @@ RUN zip default-theme.zip ./default-theme/*
|
|||||||
COPY ./admin-theme ./admin-theme/
|
COPY ./admin-theme ./admin-theme/
|
||||||
RUN zip admin-theme.zip ./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
|
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/
|
COPY --from=theme /themes/*.zip /app/
|
||||||
|
RUN mkdir data themes
|
||||||
|
|
||||||
EXPOSE 80
|
EXPOSE 80
|
||||||
CMD [ "/app/MyWebLog" ]
|
CMD [ "/app/MyWebLog" ]
|
||||||
|
Loading…
Reference in New Issue
Block a user