Skip to content

Fix: Docker - #379

Merged
AngeloTadeucci merged 1 commit into
masterfrom
dev
Mar 24, 2025
Merged

Fix: Docker#379
AngeloTadeucci merged 1 commit into
masterfrom
dev

Conversation

@AngeloTadeucci

@AngeloTadeucci AngeloTadeucci commented Mar 24, 2025

Copy link
Copy Markdown
Collaborator

Remove docker-entrypoint.sh

Summary by CodeRabbit

  • Refactor

    • Enhanced platform detection and dependency management to provide a more robust and reliable startup experience with improved error handling.
  • Chores

    • Removed legacy startup scripts and updated the container configuration to streamline the service launch process.

@coderabbitai

coderabbitai Bot commented Mar 24, 2025

Copy link
Copy Markdown
Contributor

Walkthrough

This pull request refactors the handling of the dotnet ef tool by introducing boolean flags for OS detection in Program.cs and consolidating platform-specific command execution and error handling. It updates the process for verifying, installing, and configuring the tool, including adjusting the system PATH. Additionally, the legacy docker-entrypoint.sh script is removed and the Docker Compose configuration is modified to use an array formatted entrypoint to start the application.

Changes

File(s) Changes Summary
Maple2.File.Ingest/Program.cs Introduced isWindows, isLinux, and isMac booleans for consistent OS detection; refactored commands for checking and installing dotnet ef, updated system PATH appropriately, and added error handling for failed installation/migration.
Maple2.File.Ingest/docker-entrypoint.sh Removed the Docker entrypoint shell script that previously handled dotnet ef installation and application startup.
compose.yml Changed service file-ingest configuration by replacing the string entrypoint (/app/Maple2.File.Ingest/docker-entrypoint.sh) with an array entrypoint (["dotnet", "run"]) and removed the redundant command field.

Sequence Diagram(s)

sequenceDiagram
    participant App as Program.cs
    participant OS as Operating System
    participant Installer as DotnetEF Installer
    participant DB as Database

    App->>OS: Determine OS (isWindows/isLinux/isMac)
    OS-->>App: Return OS details
    App->>App: Check for dotnet ef tool existence
    alt dotnet ef not found
        App->>Installer: Execute platform-specific install command
        Installer-->>App: Return installation result
        alt Installation successful
            App->>OS: Update system PATH (using respective OS format)
        else Installation fails
            App->>App: Throw installation exception with error message
        end
    else
        App->>DB: Execute migration command using platform check
        alt Migration fails
            App->>App: Throw migration failure exception
        end
    end
Loading

Possibly related PRs

  • Check if dotnet-ef is installed #294: Enhances platform-specific commands for checking and installing dotnet ef, directly aligning with the current changes.
  • Update setup.ps1 #349: Focuses on global installation checks for dotnet-ef, similar to the modified installation logic in this PR.
  • fix: seeding & setup #218: Modifies command-line argument handling in Program.cs, providing a code-level connection with the refactoring performed here.

Suggested reviewers

  • Zintixx

Poem

I hop through lines of neatly spun code,
With booleans to guide my lively road.
My checks now dance across Windows, Mac, and Linux,
Throwing errors only when things go askew.
I celebrate each change with a joyful bound,
A rabbit coding happily on solid ground! 🐰

✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (1)
Maple2.File.Ingest/Program.cs (1)

92-119: Effective dotnet-ef tool installation and PATH configuration

This implementation properly handles the installation of the dotnet-ef tool and updates the PATH environment variable based on the platform. This replaces functionality that was likely in the removed shell script with more maintainable C# code.

Consider adding a retry mechanism for the dotnet-ef tool installation to handle potential network issues:

    installEf.WaitForExit();
    if (installEf.ExitCode != 0) {
+       // Retry once more as network issues can sometimes cause installation to fail
+       Console.WriteLine("Failed to install dotnet-ef on first attempt. Retrying...");
+       if (isWindows) {
+           installEf = Process.Start("CMD.exe", "/C dotnet tool install --global dotnet-ef");
+       } else if (isLinux || isMac) {
+           installEf = Process.Start("bash", "-c \"dotnet tool install --global dotnet-ef\"");
+       } else {
+           throw new PlatformNotSupportedException("Unsupported OS platform");
+       }
+       installEf.WaitForExit();
+       if (installEf.ExitCode != 0) {
            throw new Exception("Failed to install dotnet-ef. Please install it manually by running 'dotnet tool install --global dotnet-ef'");
+       }
    }
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between f38788c and 2b325a9.

📒 Files selected for processing (3)
  • Maple2.File.Ingest/Program.cs (1 hunks)
  • Maple2.File.Ingest/docker-entrypoint.sh (0 hunks)
  • compose.yml (1 hunks)
💤 Files with no reviewable changes (1)
  • Maple2.File.Ingest/docker-entrypoint.sh
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: build
🔇 Additional comments (5)
compose.yml (1)

6-6: Improved Docker entrypoint configuration

The change from using a shell script entrypoint to a direct command array format is a good practice. Using the array syntax ["dotnet", "run"] ensures proper command execution without shell interpretation, which can prevent potential issues with shell escaping and improve security.

Maple2.File.Ingest/Program.cs (4)

76-78: Good refactoring with OS detection flags

Introducing boolean flags for OS detection improves code readability and maintainability by avoiding repetitive direct calls to RuntimeInformation.IsOSPlatform().


82-88: Better platform-specific command handling

The refactored code uses the boolean flags consistently to handle platform-specific command execution, which improves readability and maintainability.


126-132: Consistent platform-specific command handling

The refactored code consistently uses the boolean flags for platform-specific command execution, which improves readability and maintainability.


136-138: Improved error handling for migration failures

Adding specific error handling for migration failures will make debugging easier if there are issues with database migrations.

@AngeloTadeucci
AngeloTadeucci merged commit 8716416 into master Mar 24, 2025
@AngeloTadeucci
AngeloTadeucci deleted the dev branch March 24, 2025 06:04
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