Docker & env

This commit is contained in:
femsci 2023-11-18 12:41:04 +01:00
parent 65553534d1
commit 0ea582f464
Signed by: femsci
GPG key ID: 08F7911F0E650C67
3 changed files with 31 additions and 2 deletions

28
Dockerfile Normal file
View file

@ -0,0 +1,28 @@
FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
WORKDIR /src
COPY *.sln .
COPY src/Nyanlabs.Umogen.Core/*.csproj src/Nyanlabs.Umogen.Core/
COPY src/Nyanlabs.Umogen.Server/*.csproj src/Nyanlabs.Umogen.Server/
COPY test/Nyanlabs.Umogen.WebTests/*.csproj test/Nyanlabs.Umogen.WebTests/
COPY test/Nyanlabs.Umogen.CoreTests/*.csproj test/Nyanlabs.Umogen.CoreTests/
RUN dotnet restore
COPY . .
RUN dotnet publish -c Release -o /build
FROM mcr.microsoft.com/dotnet/aspnet:8.0
RUN apt update -y
RUN apt install -y libreoffice-writer-nogui
COPY --from=build /build /app
WORKDIR /app
EXPOSE 8080
ENTRYPOINT [ "dotnet", "Nyanlabs.Umogen.Server.dll" ]

View file

@ -8,7 +8,7 @@ public class UmoEngine : IDisposable
{ {
if (isFilePath) if (isFilePath)
{ {
apiKey ??= Umogen.DEFAULT_API_KEY_FILE; apiKey ??= Environment.GetEnvironmentVariable("UMO_KEY_FILE") ?? Umogen.DEFAULT_API_KEY_FILE;
if (!File.Exists(apiKey)) if (!File.Exists(apiKey))
{ {
throw new ArgumentException($"No such file: {apiKey}"); throw new ArgumentException($"No such file: {apiKey}");

View file

@ -11,7 +11,8 @@ public class DataContext : DbContext
protected override void OnConfiguring(DbContextOptionsBuilder o) protected override void OnConfiguring(DbContextOptionsBuilder o)
{ {
o.UseSqlite("Data Source=data.db;");
o.UseSqlite($"Data Source={Environment.GetEnvironmentVariable("UMO_DATA") ?? "data.db"};");
} }
protected override void OnModelCreating(ModelBuilder m) protected override void OnModelCreating(ModelBuilder m)