Skip to content

Conversation

gsayer
Copy link

@gsayer gsayer commented Jul 9, 2025

Overview

This PR adds Docker containerization support for the PayrollEngine Database Query Tool, enabling database initialization and management through Docker containers.

What's Changed

  • ✅ Added Dockerfile for .NET 9.0 database query tool
  • ✅ Updated project to .NET 9.0 for container compatibility
  • ✅ Updated Directory.Build.props to suppress blocking warnings
  • ✅ Configured tool for non-interactive containerized execution

Code Changes Explanation

These minimal code changes were necessary for Docker compatibility:

1. .NET 9.0 Migration

  • Files modified: DbQuery/PayrollEngine.SqlServer.DbQuery.csproj, Directory.Build.props
  • Why: .NET 9.0 provides better container support and improved CLI tools
  • Impact: Maintains full backward compatibility while enabling modern container features

2. Build Configuration

  • File modified: Directory.Build.props
  • Change: Added <WarningsAsErrors /> and <TreatWarningsAsErrors>false</TreatWarningsAsErrors>
  • Why: Nullable reference type warnings were blocking Docker builds
  • Impact: Allows compilation while maintaining code quality standards

3. Non-Interactive Execution

  • Files modified: DbQuery/Commands/TestServerCommand.cs, DbQuery/Program.cs
  • Change: Commented out Console.ReadKey() calls in containerized environments
  • Why: Container environments don't support interactive input
  • Impact: Enables automated execution without user interaction requirements

Why These Changes

  • Enables database initialization in containerized environments
  • Provides consistent database setup across different environments
  • Eliminates manual database setup steps
  • Integrates with Docker Compose for automated initialization

How to Test

  1. Build the Docker image:

    docker build -t payroll-dbquery .
  2. Run database initialization:

    docker run --rm \
      -e ConnectionStrings__DefaultConnection="Server=localhost;Database=PayrollEngine;User Id=sa;Password=PayrollEngine123!;TrustServerCertificate=True;" \
      payroll-dbquery \
      dotnet PayrollEngine.SqlServer.DbQuery.dll -server "localhost" -user "sa" -password "PayrollEngine123!" -database "PayrollEngine" -command "CreateModel"
  3. Verify database schema is created successfully

Breaking Changes

None - existing usage methods remain unchanged.

Related Issues

Part of #2 - Request for Docker Compose Stack implementation

@Giannoudis
Copy link
Contributor

The database query tool has been replaced by the admin tool. Containers are no longer required.

@Giannoudis Giannoudis closed this Jul 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants