From 8bbe863b881ae5d1220d99c6bbeb76ccdce94fb1 Mon Sep 17 00:00:00 2001 From: gsayer Date: Tue, 8 Jul 2025 20:57:13 +0200 Subject: [PATCH 1/3] feat(dbquery): add Dockerfile for DbQuery tool --- Dockerfile | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 Dockerfile diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..428f14c --- /dev/null +++ b/Dockerfile @@ -0,0 +1,22 @@ +FROM mcr.microsoft.com/dotnet/sdk:8.0 +WORKDIR /src + +# copy solution and project files +COPY ["PayrollEngine.SqlServer.DbQuery.sln", "./"] +COPY ["DbQuery/PayrollEngine.SqlServer.DbQuery.csproj", "DbQuery/"] + +# copy Directory.Build.props +COPY ["Directory.Build.props", "./"] + +RUN dotnet restore "PayrollEngine.SqlServer.DbQuery.sln" + +# copy everything else +COPY . . +WORKDIR "/src/DbQuery" +RUN dotnet publish "PayrollEngine.SqlServer.DbQuery.csproj" -c Release -o /app/publish --no-restore + +# final stage +FROM mcr.microsoft.com/dotnet/runtime:8.0 +WORKDIR /app +COPY --from=0 /app/publish . +ENTRYPOINT ["dotnet", "PayrollEngine.SqlServer.DbQuery.dll"] \ No newline at end of file From 31e376934239ebd52ae6fe32dbe7a45a944fb024 Mon Sep 17 00:00:00 2001 From: gsayer Date: Tue, 8 Jul 2025 21:38:27 +0200 Subject: [PATCH 2/3] feat: Dockerize application --- DbQuery/Program.cs | 2 +- DbQuery/TestServerCommand.cs | 6 +++--- Directory.Build.props | 2 +- Dockerfile | 4 ++-- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/DbQuery/Program.cs b/DbQuery/Program.cs index c84433c..145e69d 100644 --- a/DbQuery/Program.cs +++ b/DbQuery/Program.cs @@ -195,7 +195,7 @@ private static void ShowHelp() TestSqlConnectionCommand.ShowHelp(); TestVersionCommand.ShowHelp(); TestEmptyTableCommand.ShowHelp(); - Wait(); + // Wait(); } private static void Wait() diff --git a/DbQuery/TestServerCommand.cs b/DbQuery/TestServerCommand.cs index 444b413..4269927 100644 --- a/DbQuery/TestServerCommand.cs +++ b/DbQuery/TestServerCommand.cs @@ -115,8 +115,8 @@ internal static void ShowHelp() Console.WriteLine(" Output:"); Console.WriteLine(" Exit code -1: database server not available"); Console.WriteLine(" Exit code -2: invalid database connection string"); - Console.WriteLine(" Examples:"); - Console.WriteLine(" TestServer 'server=localhost;database=MyDatabase; Integrated Security=SSPI;TrustServerCertificate=True;' 2"); - Wait(); + Console.WriteLine("Examples:"); + Console.WriteLine(" TestServer 'server=localhost;database=MyDatabase; Integrated Security=SSPI;TrustServerCertificate=True;' 2"); + //Wait(); // disabled for docker compatibility } } \ No newline at end of file diff --git a/Directory.Build.props b/Directory.Build.props index d592c99..2c4de0a 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -1,7 +1,7 @@ - net8.0 + net9.0 1.0.16 1.0.16 1.0.16 diff --git a/Dockerfile b/Dockerfile index 428f14c..5b3f54d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM mcr.microsoft.com/dotnet/sdk:8.0 +FROM mcr.microsoft.com/dotnet/sdk:9.0 WORKDIR /src # copy solution and project files @@ -16,7 +16,7 @@ WORKDIR "/src/DbQuery" RUN dotnet publish "PayrollEngine.SqlServer.DbQuery.csproj" -c Release -o /app/publish --no-restore # final stage -FROM mcr.microsoft.com/dotnet/runtime:8.0 +FROM mcr.microsoft.com/dotnet/runtime:9.0 WORKDIR /app COPY --from=0 /app/publish . ENTRYPOINT ["dotnet", "PayrollEngine.SqlServer.DbQuery.dll"] \ No newline at end of file From f0eb45ab6df12ef3d752144c365972b09012531b Mon Sep 17 00:00:00 2001 From: gsayer Date: Tue, 8 Jul 2025 22:10:57 +0200 Subject: [PATCH 3/3] fix(dbquery): Remove interactive console waits --- DbQuery/CommandBase.cs | 2 +- DbQuery/Program.cs | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/DbQuery/CommandBase.cs b/DbQuery/CommandBase.cs index 6d7943a..4368355 100644 --- a/DbQuery/CommandBase.cs +++ b/DbQuery/CommandBase.cs @@ -25,6 +25,6 @@ protected static void Wait() { Console.WriteLine(); Console.Write("Press any key..."); - Console.ReadKey(true); + // Console.ReadKey(true); } } \ No newline at end of file diff --git a/DbQuery/Program.cs b/DbQuery/Program.cs index 145e69d..f6b8a3f 100644 --- a/DbQuery/Program.cs +++ b/DbQuery/Program.cs @@ -21,7 +21,7 @@ private async Task ExecuteAsync(string[] args) // help if (command == null) { - ShowHelp(); + // ShowHelp(); return; } @@ -198,12 +198,14 @@ private static void ShowHelp() // Wait(); } + /* private static void Wait() { Console.WriteLine(); Console.Write("Press any key..."); Console.ReadKey(true); } + */ static async Task Main(string[] args) => await new Program().ExecuteAsync(args);