From aa811eb1e3c78bdf8f4a751311c1bb6d639e851e Mon Sep 17 00:00:00 2001 From: JPVenson Date: Sun, 26 Jan 2025 20:45:28 +0000 Subject: Prepared Seperation of Database components for future multi provider support --- .devcontainer/devcontainer.json | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to '.devcontainer/devcontainer.json') diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 228d4a17c8..bcf484463b 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -24,5 +24,19 @@ "hostRequirements": { "memory": "8gb", "cpus": 4 + }, "remoteEnv": { + "JELLYFIN_DATA_DIR": "/config" + }, + "mounts": [ + "source=/opt/docker/data/jellyfin/testConfig/,target=/config,type=bind,consistency=cached", + "source=/opt/docker/data/jellyfin/config10.9.11/metadata,target=/config/metadata,type=bind,consistency=cached", + "source=/mnt/video,target=/media,type=bind,consistency=cached" + ], + "customizations": { + "vscode": { + "extensions": [ + "alexcvzz.vscode-sqlite" + ] + } } } -- cgit v1.2.3 From ce00bc076e9a97197e7e7e83276013518ce84ec5 Mon Sep 17 00:00:00 2001 From: JPVenson Date: Mon, 27 Jan 2025 18:21:47 +0000 Subject: Fixed postgres sql provider --- .devcontainer/devcontainer.json | 20 +++-------- .../DatabaseConfigurationOptions.cs | 19 +++++++++++ .../DbConfiguration/PostgreSqlOptions.cs | 39 ++++++++++++++++++++++ .../Jellyfin.Database.Providers.PgSql.csproj | 1 - .../Migrations/PgSqlDesignTimeJellyfinDbFactory.cs | 3 +- .../DatabaseConfigurationOptions.cs | 19 ----------- .../DbConfiguration/PostgreSqlOptions.cs | 39 ---------------------- .../Extensions/ServiceCollectionExtensions.cs | 3 ++ .../Jellyfin.Server.Implementations.csproj | 1 + 9 files changed, 67 insertions(+), 77 deletions(-) create mode 100644 Jellyfin.Database/Jellyfin.Database.Implementations/DbConfiguration/DatabaseConfigurationOptions.cs create mode 100644 Jellyfin.Database/Jellyfin.Database.Implementations/DbConfiguration/PostgreSqlOptions.cs delete mode 100644 Jellyfin.Server.Implementations/DbConfiguration/DatabaseConfigurationOptions.cs delete mode 100644 Jellyfin.Server.Implementations/DbConfiguration/PostgreSqlOptions.cs (limited to '.devcontainer/devcontainer.json') diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index bcf484463b..84c1dda971 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -1,6 +1,6 @@ { "name": "Development Jellyfin Server", - "image":"mcr.microsoft.com/devcontainers/dotnet:9.0-bookworm", + "image": "mcr.microsoft.com/devcontainers/dotnet:9.0-bookworm", // restores nuget packages, installs the dotnet workloads and installs the dev https certificate "postStartCommand": "sudo dotnet restore; sudo dotnet workload update; sudo dotnet dev-certs https --trust; sudo bash \"./.devcontainer/install-ffmpeg.sh\"", // reads the extensions list and installs them @@ -13,7 +13,9 @@ }, "ghcr.io/devcontainers-contrib/features/apt-packages:1": { "preserve_apt_list": false, - "packages": ["libfontconfig1"] + "packages": [ + "libfontconfig1" + ] }, "ghcr.io/devcontainers/features/docker-in-docker:2": { "dockerDashComposeVersion": "v2" @@ -24,19 +26,5 @@ "hostRequirements": { "memory": "8gb", "cpus": 4 - }, "remoteEnv": { - "JELLYFIN_DATA_DIR": "/config" - }, - "mounts": [ - "source=/opt/docker/data/jellyfin/testConfig/,target=/config,type=bind,consistency=cached", - "source=/opt/docker/data/jellyfin/config10.9.11/metadata,target=/config/metadata,type=bind,consistency=cached", - "source=/mnt/video,target=/media,type=bind,consistency=cached" - ], - "customizations": { - "vscode": { - "extensions": [ - "alexcvzz.vscode-sqlite" - ] - } } } diff --git a/Jellyfin.Database/Jellyfin.Database.Implementations/DbConfiguration/DatabaseConfigurationOptions.cs b/Jellyfin.Database/Jellyfin.Database.Implementations/DbConfiguration/DatabaseConfigurationOptions.cs new file mode 100644 index 0000000000..d49d8536a3 --- /dev/null +++ b/Jellyfin.Database/Jellyfin.Database.Implementations/DbConfiguration/DatabaseConfigurationOptions.cs @@ -0,0 +1,19 @@ +using System; + +namespace Jellyfin.Server.Implementations.DatabaseConfiguration; + +/// +/// Options to configure jellyfins managed database. +/// +public class DatabaseConfigurationOptions +{ + /// + /// Gets or Sets the type of database jellyfin should use. + /// + public required string DatabaseType { get; set; } + + /// + /// Gets or Sets the settings to run jellyfin with Postgres. + /// + public PostgreSqlOptions? PostgreSql { get; set; } +} diff --git a/Jellyfin.Database/Jellyfin.Database.Implementations/DbConfiguration/PostgreSqlOptions.cs b/Jellyfin.Database/Jellyfin.Database.Implementations/DbConfiguration/PostgreSqlOptions.cs new file mode 100644 index 0000000000..1f7c30b098 --- /dev/null +++ b/Jellyfin.Database/Jellyfin.Database.Implementations/DbConfiguration/PostgreSqlOptions.cs @@ -0,0 +1,39 @@ +using System; + +namespace Jellyfin.Server.Implementations.DatabaseConfiguration; + +/// +/// Options specific to run jellyfin on a postgreSql database. +/// +public class PostgreSqlOptions +{ + /// + /// Gets or Sets the Port. Defaults to 5432. + /// + public required int Port { get; set; } = 5432; + + /// + /// Gets or Sets the Server name. + /// + public required string ServerName { get; set; } + + /// + /// Gets or Sets the username. + /// + public required string Username { get; set; } + + /// + /// Gets or Sets the password. + /// + public required string Password { get; set; } + + /// + /// Gets or Sets the database name. Defaults to "Jellyfin". + /// + public string DatabaseName { get; set; } = "Jellyfin"; + + /// + /// Gets or Sets the timeout in secounds before a running command is terminated. Defaults to 30. + /// + public int Timeout { get; set; } = 30; +} diff --git a/Jellyfin.Database/Jellyfin.Database.Providers.PgSql/Jellyfin.Database.Providers.PgSql.csproj b/Jellyfin.Database/Jellyfin.Database.Providers.PgSql/Jellyfin.Database.Providers.PgSql.csproj index ae1497403b..785a3c63ab 100644 --- a/Jellyfin.Database/Jellyfin.Database.Providers.PgSql/Jellyfin.Database.Providers.PgSql.csproj +++ b/Jellyfin.Database/Jellyfin.Database.Providers.PgSql/Jellyfin.Database.Providers.PgSql.csproj @@ -45,7 +45,6 @@ - diff --git a/Jellyfin.Database/Jellyfin.Database.Providers.PgSql/Migrations/PgSqlDesignTimeJellyfinDbFactory.cs b/Jellyfin.Database/Jellyfin.Database.Providers.PgSql/Migrations/PgSqlDesignTimeJellyfinDbFactory.cs index 8f5e2e82b2..bf949d570b 100644 --- a/Jellyfin.Database/Jellyfin.Database.Providers.PgSql/Migrations/PgSqlDesignTimeJellyfinDbFactory.cs +++ b/Jellyfin.Database/Jellyfin.Database.Providers.PgSql/Migrations/PgSqlDesignTimeJellyfinDbFactory.cs @@ -1,4 +1,3 @@ -using Jellyfin.Database.Providers.SqLite; using Jellyfin.Server.Implementations; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Design; @@ -20,7 +19,7 @@ namespace Jellyfin.Database.Providers.PgSql return new JellyfinDbContext( optionsBuilder.Options, NullLogger.Instance, - new SqliteDatabaseProvider(null!, NullLogger.Instance)); + new PgSqlDatabaseProvider(null!, NullLogger.Instance)); } } } diff --git a/Jellyfin.Server.Implementations/DbConfiguration/DatabaseConfigurationOptions.cs b/Jellyfin.Server.Implementations/DbConfiguration/DatabaseConfigurationOptions.cs deleted file mode 100644 index d49d8536a3..0000000000 --- a/Jellyfin.Server.Implementations/DbConfiguration/DatabaseConfigurationOptions.cs +++ /dev/null @@ -1,19 +0,0 @@ -using System; - -namespace Jellyfin.Server.Implementations.DatabaseConfiguration; - -/// -/// Options to configure jellyfins managed database. -/// -public class DatabaseConfigurationOptions -{ - /// - /// Gets or Sets the type of database jellyfin should use. - /// - public required string DatabaseType { get; set; } - - /// - /// Gets or Sets the settings to run jellyfin with Postgres. - /// - public PostgreSqlOptions? PostgreSql { get; set; } -} diff --git a/Jellyfin.Server.Implementations/DbConfiguration/PostgreSqlOptions.cs b/Jellyfin.Server.Implementations/DbConfiguration/PostgreSqlOptions.cs deleted file mode 100644 index 1f7c30b098..0000000000 --- a/Jellyfin.Server.Implementations/DbConfiguration/PostgreSqlOptions.cs +++ /dev/null @@ -1,39 +0,0 @@ -using System; - -namespace Jellyfin.Server.Implementations.DatabaseConfiguration; - -/// -/// Options specific to run jellyfin on a postgreSql database. -/// -public class PostgreSqlOptions -{ - /// - /// Gets or Sets the Port. Defaults to 5432. - /// - public required int Port { get; set; } = 5432; - - /// - /// Gets or Sets the Server name. - /// - public required string ServerName { get; set; } - - /// - /// Gets or Sets the username. - /// - public required string Username { get; set; } - - /// - /// Gets or Sets the password. - /// - public required string Password { get; set; } - - /// - /// Gets or Sets the database name. Defaults to "Jellyfin". - /// - public string DatabaseName { get; set; } = "Jellyfin"; - - /// - /// Gets or Sets the timeout in secounds before a running command is terminated. Defaults to 30. - /// - public int Timeout { get; set; } = 30; -} diff --git a/Jellyfin.Server.Implementations/Extensions/ServiceCollectionExtensions.cs b/Jellyfin.Server.Implementations/Extensions/ServiceCollectionExtensions.cs index 091ecee987..7936c6fd98 100644 --- a/Jellyfin.Server.Implementations/Extensions/ServiceCollectionExtensions.cs +++ b/Jellyfin.Server.Implementations/Extensions/ServiceCollectionExtensions.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using System.IO; using System.Linq; using System.Reflection; +using Jellyfin.Database.Providers.PgSql; using Jellyfin.Database.Providers.SqLite; using Jellyfin.Server.Implementations.DatabaseConfiguration; using MediaBrowser.Common.Configuration; @@ -22,6 +23,7 @@ public static class ServiceCollectionExtensions private static IEnumerable DatabaseProviderTypes() { yield return typeof(SqliteDatabaseProvider); + yield return typeof(PgSqlDatabaseProvider); } private static IDictionary GetSupportedDbProviders() @@ -75,6 +77,7 @@ public static class ServiceCollectionExtensions { DatabaseType = "Jellyfin-SqLite", }; + configurationManager.SaveConfiguration("database", efCoreConfiguration); } } diff --git a/Jellyfin.Server.Implementations/Jellyfin.Server.Implementations.csproj b/Jellyfin.Server.Implementations/Jellyfin.Server.Implementations.csproj index b566b3489b..01d9dcf64d 100644 --- a/Jellyfin.Server.Implementations/Jellyfin.Server.Implementations.csproj +++ b/Jellyfin.Server.Implementations/Jellyfin.Server.Implementations.csproj @@ -37,6 +37,7 @@ + -- cgit v1.2.3 From 74858042fce56eeb7af5cf991569fee0dca50775 Mon Sep 17 00:00:00 2001 From: JPVenson Date: Mon, 27 Jan 2025 19:14:11 +0000 Subject: Added devcontainer for pgsql development --- .devcontainer/devcontainer.json | 2 ++ .devcontainer/pgsql/Dockerfile | 2 +- .devcontainer/pgsql/devcontainer.json | 5 +++-- .devcontainer/pgsql/docker-compose.yaml | 2 +- 4 files changed, 7 insertions(+), 4 deletions(-) (limited to '.devcontainer/devcontainer.json') diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 84c1dda971..bcdd82cb9a 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -1,6 +1,8 @@ { "name": "Development Jellyfin Server", "image": "mcr.microsoft.com/devcontainers/dotnet:9.0-bookworm", + "service": "app", + "workspaceFolder": "/workspaces/${localWorkspaceFolderBasename}", // restores nuget packages, installs the dotnet workloads and installs the dev https certificate "postStartCommand": "sudo dotnet restore; sudo dotnet workload update; sudo dotnet dev-certs https --trust; sudo bash \"./.devcontainer/install-ffmpeg.sh\"", // reads the extensions list and installs them diff --git a/.devcontainer/pgsql/Dockerfile b/.devcontainer/pgsql/Dockerfile index 800bec76f8..ff7f3bcd79 100644 --- a/.devcontainer/pgsql/Dockerfile +++ b/.devcontainer/pgsql/Dockerfile @@ -1,4 +1,4 @@ -FROM mcr.microsoft.com/devcontainers/dotnet:1-8.0-bookworm +FROM mcr.microsoft.com/devcontainers/dotnet:9.0-bookworm # [Optional] Uncomment this section to install additional OS packages. # RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \ diff --git a/.devcontainer/pgsql/devcontainer.json b/.devcontainer/pgsql/devcontainer.json index db7f84c89c..7fb09fdc9c 100644 --- a/.devcontainer/pgsql/devcontainer.json +++ b/.devcontainer/pgsql/devcontainer.json @@ -1,7 +1,8 @@ { "name": "Development Jellyfin Server", - "image": "mcr.microsoft.com/devcontainers/dotnet:9.0-bookworm", - "dockerComposeFile": "docker-compose.yml", + "dockerComposeFile": "docker-compose.yaml", + "service": "app", + "workspaceFolder": "/workspaces/${localWorkspaceFolderBasename}", // restores nuget packages, installs the dotnet workloads and installs the dev https certificate "postStartCommand": "sudo dotnet restore; sudo dotnet workload update; sudo dotnet dev-certs https --trust; sudo bash \"./.devcontainer/install-ffmpeg.sh\"", // reads the extensions list and installs them diff --git a/.devcontainer/pgsql/docker-compose.yaml b/.devcontainer/pgsql/docker-compose.yaml index 88954d5644..891a03673f 100644 --- a/.devcontainer/pgsql/docker-compose.yaml +++ b/.devcontainer/pgsql/docker-compose.yaml @@ -7,7 +7,7 @@ services: dockerfile: Dockerfile volumes: - - ../..:/workspaces:cached + - ../../..:/workspaces:cached # Overrides default command so things don't shut down after the process ends. command: sleep infinity -- cgit v1.2.3 From 4b57f2bdbba74093daf79dbf54b397baafba4512 Mon Sep 17 00:00:00 2001 From: JPVenson Date: Sun, 2 Feb 2025 02:10:14 +0000 Subject: Fixed whitespace formatting --- .devcontainer/devcontainer.json | 2 +- .devcontainer/pgsql/devcontainer.json | 28 +++++++++++++++------------- .devcontainer/pgsql/docker-compose.yaml | 2 -- 3 files changed, 16 insertions(+), 16 deletions(-) (limited to '.devcontainer/devcontainer.json') diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index bcdd82cb9a..c2127ba5c3 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -2,7 +2,7 @@ "name": "Development Jellyfin Server", "image": "mcr.microsoft.com/devcontainers/dotnet:9.0-bookworm", "service": "app", - "workspaceFolder": "/workspaces/${localWorkspaceFolderBasename}", + "workspaceFolder": "/workspaces/${localWorkspaceFolderBasename}", // restores nuget packages, installs the dotnet workloads and installs the dev https certificate "postStartCommand": "sudo dotnet restore; sudo dotnet workload update; sudo dotnet dev-certs https --trust; sudo bash \"./.devcontainer/install-ffmpeg.sh\"", // reads the extensions list and installs them diff --git a/.devcontainer/pgsql/devcontainer.json b/.devcontainer/pgsql/devcontainer.json index 7fb09fdc9c..3dd91d9755 100644 --- a/.devcontainer/pgsql/devcontainer.json +++ b/.devcontainer/pgsql/devcontainer.json @@ -2,24 +2,26 @@ "name": "Development Jellyfin Server", "dockerComposeFile": "docker-compose.yaml", "service": "app", - "workspaceFolder": "/workspaces/${localWorkspaceFolderBasename}", + "workspaceFolder": "/workspaces/${localWorkspaceFolderBasename}", // restores nuget packages, installs the dotnet workloads and installs the dev https certificate "postStartCommand": "sudo dotnet restore; sudo dotnet workload update; sudo dotnet dev-certs https --trust; sudo bash \"./.devcontainer/install-ffmpeg.sh\"", // reads the extensions list and installs them "postAttachCommand": "cat .vscode/extensions.json | jq -r .recommendations[] | xargs -n 1 code --install-extension", - "forwardPorts": ["pgadmin:8081"], - "portsAttributes": { - "8081": { - "label": "pgAdmin", - "onAutoForward": "notify", - "requireLocalPort": true - }, + "forwardPorts": [ + "pgadmin:8081" + ], + "portsAttributes": { + "8081": { + "label": "pgAdmin", + "onAutoForward": "notify", + "requireLocalPort": true + }, "8096": { - "label": "jellyfinapi", - "onAutoForward": "notify", - "requireLocalPort": true - } - }, + "label": "jellyfinapi", + "onAutoForward": "notify", + "requireLocalPort": true + } + }, "features": { "ghcr.io/devcontainers/features/dotnet:2": { "version": "none", diff --git a/.devcontainer/pgsql/docker-compose.yaml b/.devcontainer/pgsql/docker-compose.yaml index dda6deda69..45af0b33e1 100644 --- a/.devcontainer/pgsql/docker-compose.yaml +++ b/.devcontainer/pgsql/docker-compose.yaml @@ -14,7 +14,6 @@ services: # Runs app on the same network as the database container, allows "forwardPorts" in devcontainer.json function. network_mode: service:pgadmin - # Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root. # user: root @@ -42,7 +41,6 @@ services: - PGADMIN_LISTEN_PORT=8081 - PGADMIN_SERVER_JSON_FILE=/pgadmin/servers.json - PGADMIN_CONFIG_SERVER_MODE=False - # Add "forwardPorts": ["5432"] to **devcontainer.json** to forward PostgreSQL locally. # (Adding the "ports" property to this file will not forward from a Codespace.) -- cgit v1.2.3