Compare commits
6 commits
8e11008d58
...
8c605ba902
| Author | SHA1 | Date | |
|---|---|---|---|
| 8c605ba902 | |||
| 7090092565 | |||
| a5453c8191 | |||
| 0359732385 | |||
| 2746bd84ed | |||
| 0035ed14a8 |
8 changed files with 57 additions and 34 deletions
|
|
@ -21,5 +21,7 @@
|
|||
**/obj
|
||||
**/secrets.dev.yaml
|
||||
**/values.dev.yaml
|
||||
**/*.db*
|
||||
**/docker_data
|
||||
LICENSE
|
||||
README.md
|
||||
README.md
|
||||
|
|
|
|||
25
Dockerfile
Normal file
25
Dockerfile
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS base
|
||||
USER $APP_UID
|
||||
WORKDIR /app
|
||||
EXPOSE 8080
|
||||
|
||||
FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
|
||||
ARG BUILD_CONFIGURATION=Release
|
||||
WORKDIR /src
|
||||
COPY ["FreeTubeSync/FreeTubeSync.csproj", "FreeTubeSync/"]
|
||||
RUN dotnet restore "FreeTubeSync/FreeTubeSync.csproj"
|
||||
COPY . .
|
||||
WORKDIR "/src/FreeTubeSync"
|
||||
RUN dotnet build "./FreeTubeSync.csproj" -c $BUILD_CONFIGURATION -o /app/build
|
||||
|
||||
FROM build AS publish
|
||||
ARG BUILD_CONFIGURATION=Release
|
||||
RUN dotnet publish "./FreeTubeSync.csproj" -c $BUILD_CONFIGURATION -o /app/publish /p:UseAppHost=false
|
||||
|
||||
FROM base AS final
|
||||
WORKDIR /app
|
||||
COPY --from=publish /app/publish .
|
||||
RUN mkdir data
|
||||
RUN chmod a+rw data
|
||||
VOLUME /app/data
|
||||
ENTRYPOINT ["dotnet", "FreeTubeSync.dll"]
|
||||
|
|
@ -10,11 +10,6 @@ public class DataContext : DbContext
|
|||
|
||||
}
|
||||
|
||||
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
|
||||
{
|
||||
optionsBuilder.UseSqlite("Data Source=FreeTubeSync.db");
|
||||
}
|
||||
|
||||
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
||||
{
|
||||
modelBuilder.Entity<Setting>()
|
||||
|
|
|
|||
|
|
@ -1,23 +0,0 @@
|
|||
FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS base
|
||||
USER $APP_UID
|
||||
WORKDIR /app
|
||||
EXPOSE 8080
|
||||
EXPOSE 8081
|
||||
|
||||
FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
|
||||
ARG BUILD_CONFIGURATION=Release
|
||||
WORKDIR /src
|
||||
COPY ["FreeTubeSync2/FreeTubeSync2.csproj", "FreeTubeSync2/"]
|
||||
RUN dotnet restore "FreeTubeSync2/FreeTubeSync2.csproj"
|
||||
COPY . .
|
||||
WORKDIR "/src/FreeTubeSync2"
|
||||
RUN dotnet build "./FreeTubeSync2.csproj" -c $BUILD_CONFIGURATION -o /app/build
|
||||
|
||||
FROM build AS publish
|
||||
ARG BUILD_CONFIGURATION=Release
|
||||
RUN dotnet publish "./FreeTubeSync2.csproj" -c $BUILD_CONFIGURATION -o /app/publish /p:UseAppHost=false
|
||||
|
||||
FROM base AS final
|
||||
WORKDIR /app
|
||||
COPY --from=publish /app/publish .
|
||||
ENTRYPOINT ["dotnet", "FreeTubeSync2.dll"]
|
||||
|
|
@ -1,13 +1,15 @@
|
|||
using FreeTubeSync;
|
||||
using FreeTubeSync.Database;
|
||||
using FreeTubeSync.EndPoints;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
var builder = WebApplication.CreateBuilder(args);
|
||||
|
||||
builder.Services.AddEndpointsApiExplorer();
|
||||
builder.Services.AddSwaggerGen();
|
||||
|
||||
builder.Services.AddDbContext<DataContext>();
|
||||
builder.Services.AddDbContext<DataContext>(options =>
|
||||
options.UseSqlite(builder.Configuration.GetConnectionString("FreeTubeSync")));
|
||||
|
||||
builder.Services.AddScoped(typeof(IRepository<>), typeof(Repository<>));
|
||||
|
||||
|
|
@ -21,4 +23,17 @@ app.MapProfileEndpoints();
|
|||
app.MapSearchHistoryEndpoints();
|
||||
app.MapSettingEndpoints();
|
||||
|
||||
await using(var serviceScope = app.Services.CreateAsyncScope())
|
||||
await using (var dbContext = serviceScope.ServiceProvider.GetRequiredService<DataContext>())
|
||||
{
|
||||
try
|
||||
{
|
||||
await dbContext.Database.MigrateAsync();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
await dbContext.Database.EnsureCreatedAsync();
|
||||
}
|
||||
}
|
||||
|
||||
app.Run();
|
||||
|
|
@ -1,4 +1,7 @@
|
|||
{
|
||||
"ConnectionStrings": {
|
||||
"FreeTubeSync": "Data Source=../data/FreeTubeSync.db"
|
||||
},
|
||||
"Logging": {
|
||||
"LogLevel": {
|
||||
"Default": "Information",
|
||||
|
|
|
|||
|
|
@ -1,4 +1,7 @@
|
|||
{
|
||||
"ConnectionStrings": {
|
||||
"FreeTubeSync": "Data Source=/app/data/FreeTubeSync.db"
|
||||
},
|
||||
"Logging": {
|
||||
"LogLevel": {
|
||||
"Default": "Information",
|
||||
|
|
|
|||
11
compose.yaml
11
compose.yaml
|
|
@ -1,7 +1,10 @@
|
|||
services:
|
||||
freetubesync2:
|
||||
image: freetubesync2
|
||||
freetubesync:
|
||||
image: freetubesync
|
||||
build:
|
||||
context: .
|
||||
dockerfile: FreeTubeSync2/Dockerfile
|
||||
|
||||
dockerfile: FreeTubeSync/Dockerfile
|
||||
ports:
|
||||
- "8080:8080"
|
||||
volumes:
|
||||
- ./docker_data:/data
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue