Compare commits

...

6 commits

Author SHA1 Message Date
8c605ba902 Updated Docker Compose
Added docker compose to mount Volume for Data.
2025-07-21 13:07:55 -05:00
7090092565 Added to Dockerignore
Added folders that do not need to be in docker.
2025-07-21 13:07:21 -05:00
a5453c8191 Updated App Settings
Added FreeTubeSync database connection strings.
2025-07-21 13:06:55 -05:00
0359732385 Updated Program
Updated Program to have SQLite Configuration done through Connection
Strings.
Added auto migration for the database, if we get an exception, we create
the database instead (As it doesn't exist.)
2025-07-21 13:06:27 -05:00
2746bd84ed Moved Dockerfile
Moved dockerfile into root Solution folder.
2025-07-21 13:04:15 -05:00
0035ed14a8 Updated DataContext
Removed OnConfiguring(), as this is done in Program.cs now.
2025-07-21 13:03:51 -05:00
8 changed files with 57 additions and 34 deletions

View file

@ -21,5 +21,7 @@
**/obj
**/secrets.dev.yaml
**/values.dev.yaml
**/*.db*
**/docker_data
LICENSE
README.md
README.md

25
Dockerfile Normal file
View 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"]

View file

@ -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>()

View file

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

View file

@ -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();

View file

@ -1,4 +1,7 @@
{
"ConnectionStrings": {
"FreeTubeSync": "Data Source=../data/FreeTubeSync.db"
},
"Logging": {
"LogLevel": {
"Default": "Information",

View file

@ -1,4 +1,7 @@
{
"ConnectionStrings": {
"FreeTubeSync": "Data Source=/app/data/FreeTubeSync.db"
},
"Logging": {
"LogLevel": {
"Default": "Information",

View file

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