From 85c9bc1f57d4d8c40d7506e1618bcd65bebd57cd Mon Sep 17 00:00:00 2001 From: whimsical-c4lic0 Date: Tue, 10 Feb 2026 03:06:15 -0600 Subject: [PATCH] Fix docker builds --- .gitattributes | 5 ++++ Dockerfile | 3 +- OF DL.Core/Services/ConfigService.cs | 32 +++++++++++---------- OF DL/Program.cs | 42 +++++++++++++++++----------- 4 files changed, 50 insertions(+), 32 deletions(-) diff --git a/.gitattributes b/.gitattributes index 1ff0c42..06ec5e7 100644 --- a/.gitattributes +++ b/.gitattributes @@ -3,6 +3,11 @@ ############################################################################### * text=auto +############################################################################### +# Shell scripts should use LF line endings (avoid /bin/sh^M issues in containers) +############################################################################### +*.sh text eol=lf + ############################################################################### # Set default behavior for command prompt diff. # diff --git a/Dockerfile b/Dockerfile index 1307df3..013ab31 100644 --- a/Dockerfile +++ b/Dockerfile @@ -8,11 +8,12 @@ RUN apk --no-cache --repository community add \ # Copy source code COPY ["OF DL.sln", "/src/OF DL.sln"] COPY ["OF DL", "/src/OF DL"] +COPY ["OF DL.Core", "/src/OF DL.Core"] WORKDIR "/src" # Build release -RUN dotnet publish -p:WarningLevel=0 -p:Version=$VERSION -c Release --self-contained true -p:PublishSingleFile=true -o out +RUN dotnet publish "OF DL/OF DL.csproj" -p:WarningLevel=0 -p:Version=$VERSION -c Release -o out # Generate default config.conf files RUN /src/out/OF\ DL --non-interactive || true && \ diff --git a/OF DL.Core/Services/ConfigService.cs b/OF DL.Core/Services/ConfigService.cs index d49a987..6de7c00 100644 --- a/OF DL.Core/Services/ConfigService.cs +++ b/OF DL.Core/Services/ConfigService.cs @@ -20,6 +20,21 @@ public class ConfigService(ILoggingService loggingService) : IConfigService try { IsCliNonInteractive = false; + if (args.Length > 0) + { + const string nonInteractiveArg = "--non-interactive"; + if (args.Any(a => a.Equals(nonInteractiveArg, StringComparison.OrdinalIgnoreCase))) + { + IsCliNonInteractive = true; + Log.Debug("NonInteractiveMode set via command line"); + } + + Log.Debug("Additional arguments:"); + foreach (string argument in args) + { + Log.Debug(argument); + } + } // Migrate from config.json to config.conf if needed await MigrateFromJsonToConfAsync(); @@ -43,21 +58,10 @@ public class ConfigService(ILoggingService loggingService) : IConfigService } } - // Check for command-line arguments - if (args.Length > 0) + if (IsCliNonInteractive && !CurrentConfig.NonInteractiveMode) { - const string NON_INTERACTIVE_ARG = "--non-interactive"; - if (args.Any(a => a.Equals(NON_INTERACTIVE_ARG, StringComparison.OrdinalIgnoreCase))) - { - IsCliNonInteractive = true; - Log.Debug("NonInteractiveMode set via command line"); - } - - Log.Debug("Additional arguments:"); - foreach (string argument in args) - { - Log.Debug(argument); - } + CurrentConfig.NonInteractiveMode = true; + Log.Debug("NonInteractiveMode overridden to true via command line"); } return true; diff --git a/OF DL/Program.cs b/OF DL/Program.cs index 31339ba..fd3150c 100644 --- a/OF DL/Program.cs +++ b/OF DL/Program.cs @@ -94,9 +94,9 @@ public class Program(IServiceProvider serviceProvider) if (!await configService.LoadConfigurationAsync(args)) { AnsiConsole.MarkupLine("\n[red]config.conf is not valid, check your syntax![/]\n"); - AnsiConsole.MarkupLine("[red]Press any key to exit.[/]"); if (!configService.IsCliNonInteractive) { + AnsiConsole.MarkupLine("[red]Press any key to exit.[/]"); Console.ReadKey(); } @@ -146,10 +146,9 @@ public class Program(IServiceProvider serviceProvider) Console.Write( "OF-DL requires Windows 10 or higher when being run on Windows. Your reported version is: {0}\n\n", startupResult.OsVersionString); - Console.Write("Press any key to continue.\n"); - if (!configService.CurrentConfig.NonInteractiveMode) { + Console.Write("Press any key to continue.\n"); Console.ReadKey(); } @@ -158,12 +157,17 @@ public class Program(IServiceProvider serviceProvider) if (!startupResult.FfmpegFound) { - AnsiConsole.Markup( - "[red]Cannot locate FFmpeg; please modify config.conf with the correct path. Press any key to exit.[/]"); if (!configService.CurrentConfig.NonInteractiveMode) { + AnsiConsole.Markup( + "[red]Cannot locate FFmpeg; please modify config.conf with the correct path. Press any key to exit.[/]"); Console.ReadKey(); } + else + { + AnsiConsole.Markup( + "[red]Cannot locate FFmpeg; please modify config.conf with the correct path.[/]"); + } Environment.Exit(4); } @@ -210,7 +214,11 @@ public class Program(IServiceProvider serviceProvider) AnsiConsole.MarkupLine( "\n[red]Auth failed. Please try again or use other authentication methods detailed here:[/]\n"); AnsiConsole.MarkupLine("[link]https://docs.ofdl.tools/config/auth[/]\n"); - Console.ReadKey(); + if (!configService.CurrentConfig.NonInteractiveMode) + { + Console.WriteLine("\nPress any key to exit."); + Console.ReadKey(); + } Environment.Exit(2); } } @@ -234,9 +242,9 @@ public class Program(IServiceProvider serviceProvider) ex.InnerException.StackTrace); } - Console.WriteLine("\nPress any key to exit."); if (!configService.CurrentConfig.NonInteractiveMode) { + Console.WriteLine("\nPress any key to exit."); Console.ReadKey(); } @@ -737,9 +745,6 @@ public class Program(IServiceProvider serviceProvider) AnsiConsole.MarkupLine( "[red]You may also want to try using the browser extension which is documented here:[/]\n"); AnsiConsole.MarkupLine("[link]https://docs.ofdl.tools/config/auth/#legacy-methods[/]"); - AnsiConsole.MarkupLine("[red]Press any key to exit.[/]"); - - Console.ReadKey(); Environment.Exit(2); } @@ -749,14 +754,14 @@ public class Program(IServiceProvider serviceProvider) } else { - ShowAuthMissingError(); + ShowAuthMissingError(configService.CurrentConfig.NonInteractiveMode); } } else { if (configService.CurrentConfig.NonInteractiveMode) { - ShowAuthMissingError(); + ShowAuthMissingError(configService.CurrentConfig.NonInteractiveMode); } else if (!configService.CurrentConfig.DisableBrowserAuth) { @@ -764,21 +769,24 @@ public class Program(IServiceProvider serviceProvider) } else { - ShowAuthMissingError(); + ShowAuthMissingError(configService.CurrentConfig.NonInteractiveMode); } } } - private static void ShowAuthMissingError() + private static void ShowAuthMissingError(bool nonInteractiveMode) { AnsiConsole.MarkupLine( "\n[red]auth.json is missing. The file can be generated automatically when OF-DL is run in the standard, interactive mode.[/]\n"); AnsiConsole.MarkupLine( "[red]You may also want to try using the browser extension which is documented here:[/]\n"); AnsiConsole.MarkupLine("[link]https://docs.ofdl.tools/config/auth/#legacy-methods[/]"); - AnsiConsole.MarkupLine("[red]Press any key to exit.[/]"); - Console.ReadKey(); + if (!nonInteractiveMode) + { + AnsiConsole.MarkupLine("[red]Press any key to exit.[/]"); + Console.ReadKey(); + } Environment.Exit(2); } @@ -881,11 +889,11 @@ public class Program(IServiceProvider serviceProvider) { AnsiConsole.MarkupLine("\n[red]rules.json is not valid, check your JSON syntax![/]\n"); AnsiConsole.MarkupLine("[red]Please ensure you are using the latest version of the software.[/]\n"); - AnsiConsole.MarkupLine("[red]Press any key to exit.[/]"); Log.Error("rules.json processing failed: {Error}", result.RulesJsonError); if (!configService.CurrentConfig.NonInteractiveMode) { + AnsiConsole.MarkupLine("[red]Press any key to exit.[/]"); Console.ReadKey(); }