Add Sqlite Docker file

- Fix import typo in RethinkDB upload restore
- Switch default Docker file to alpine image
This commit is contained in:
Daniel J. Summers 2023-07-18 21:53:04 -04:00
parent 5f5927c425
commit 9dd6ab70e9
3 changed files with 38 additions and 6 deletions

View File

@ -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 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 net7.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,10 +19,12 @@ 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:7.0-alpine as final
WORKDIR /app 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/net7.0/linux-x64/publish/ ./
COPY --from=theme /themes/*.zip /app/ COPY --from=theme /themes/*.zip /app/
EXPOSE 80 EXPOSE 80
CMD [ "/app/MyWebLog" ] CMD [ "dotnet", "/app/MyWebLog.dll" ]

View File

@ -226,7 +226,9 @@ type RethinkDbData (conn : Net.IConnection, config : DataConfig, log : ILogger<R
match version with match version with
| Some v when v = "v2" -> () | Some v when v = "v2" -> ()
| Some v when v = "v2-rc2" -> do! migrateV2Rc2ToV2 () | 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 _ | Some _
| None -> | None ->
log.LogWarning $"Unknown database version; assuming {Utils.currentDbVersion}" log.LogWarning $"Unknown database version; assuming {Utils.currentDbVersion}"
@ -926,7 +928,7 @@ type RethinkDbData (conn : Net.IConnection, config : DataConfig, log : ILogger<R
// Files can be large; we'll do 5 at a time // Files can be large; we'll do 5 at a time
for batch in uploads |> List.chunkBySize 5 do for batch in uploads |> List.chunkBySize 5 do
do! rethink { do! rethink {
withTable Table.TagMap withTable Table.Upload
insert batch insert batch
write; withRetryOnce; ignoreResult conn write; withRetryOnce; ignoreResult conn
} }

28
src/sqlite.Dockerfile Normal file
View File

@ -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" ]