From 9dd6ab70e969edd2662603eca34c91e82ea8c3ba Mon Sep 17 00:00:00 2001 From: "Daniel J. Summers" Date: Tue, 18 Jul 2023 21:53:04 -0400 Subject: [PATCH] Add Sqlite Docker file - Fix import typo in RethinkDB upload restore - Switch default Docker file to alpine image --- src/Dockerfile | 10 ++++++---- src/MyWebLog.Data/RethinkDbData.fs | 6 ++++-- src/sqlite.Dockerfile | 28 ++++++++++++++++++++++++++++ 3 files changed, 38 insertions(+), 6 deletions(-) create mode 100644 src/sqlite.Dockerfile diff --git a/src/Dockerfile b/src/Dockerfile index cf71ceb..d05e417 100644 --- a/src/Dockerfile +++ b/src/Dockerfile @@ -1,4 +1,4 @@ -FROM mcr.microsoft.com/dotnet/sdk:7.0 AS build +FROM mcr.microsoft.com/dotnet/sdk:7.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 +RUN dotnet publish -f net7.0 -c Release -r linux-x64 --no-self-contained -p:PublishSingleFile=false FROM alpine AS theme RUN apk add --no-cache zip @@ -19,10 +19,12 @@ 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:7.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=theme /themes/*.zip /app/ EXPOSE 80 -CMD [ "/app/MyWebLog" ] +CMD [ "dotnet", "/app/MyWebLog.dll" ] diff --git a/src/MyWebLog.Data/RethinkDbData.fs b/src/MyWebLog.Data/RethinkDbData.fs index 92ace6e..9cf340e 100644 --- a/src/MyWebLog.Data/RethinkDbData.fs +++ b/src/MyWebLog.Data/RethinkDbData.fs @@ -226,7 +226,9 @@ type RethinkDbData (conn : Net.IConnection, config : DataConfig, log : ILogger () | Some v when v = "v2-rc2" -> do! migrateV2Rc2ToV2 () - | Some v when v = "v2-rc1" -> do! migrateV2Rc1ToV2Rc2 () + | Some v when v = "v2-rc1" -> + do! migrateV2Rc1ToV2Rc2 () + do! migrateV2Rc2ToV2 () | Some _ | None -> log.LogWarning $"Unknown database version; assuming {Utils.currentDbVersion}" @@ -926,7 +928,7 @@ type RethinkDbData (conn : Net.IConnection, config : DataConfig, log : ILogger List.chunkBySize 5 do do! rethink { - withTable Table.TagMap + withTable Table.Upload insert batch write; withRetryOnce; ignoreResult conn } diff --git a/src/sqlite.Dockerfile b/src/sqlite.Dockerfile new file mode 100644 index 0000000..cf71ceb --- /dev/null +++ b/src/sqlite.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" ]