Skip to content

feat: exit if docker buildx can't be found for self-hosted builds #1475

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Nov 18, 2024

Conversation

ghostdevv
Copy link
Contributor

@ghostdevv ghostdevv commented Nov 17, 2024

I ran into an issue when using trigger that I docker would fail to build as it couldn't find the --progress flag. This flag is only available when docker buildx is installed. This change adds in a check to see if docker buildx is installed, and if it's not it'll fail with a helpful message.

When buildx is installed the docker buildx version command will return a version, if it's not then the command will fail.

image

(install-docker-buildx isn't a real command, I just wrapped the arch linux yay -S docker-buildx for the demo)

We can then test the warning I added based on this

image

Additionally, I added a debug log for this. You can test that by running trigger deploy --self-hosted --log-level debug, and you'll get something like this at the end of the log:

image

Edit: added a better build message based on rabbit's suggestion

image

✅ Checklist

  • I have followed every step in the contributing guide
  • The PR title follows the convention.
  • I ran and tested the code works

Summary by CodeRabbit

  • New Features

    • Enhanced deployment command functionality with checks for Docker Buildx during self-hosted builds.
    • Added visual feedback with a spinner during the build process.
  • Bug Fixes

    • Improved error handling for deployment failures and environment variable synchronization.
  • Chores

    • Updated tinyexec dependency to version ^0.3.1.
    • Updated package.json to version 3.2.0 and refined module export structure.

Copy link
Contributor

coderabbitai bot commented Nov 17, 2024

Walkthrough

The changes introduced in this pull request enhance the deployment process within the trigger.dev CLI. A new feature has been added to check for the presence of the docker buildx tool during self-hosted builds, ensuring that the process exits if the tool is not found. Additionally, the package.json file has been updated to reflect a new version and modified dependency structure. The deploy.ts file has also been improved with refined error handling, user feedback mechanisms, and logging adjustments to enhance the overall deployment experience.

Changes

File Path Change Summary
.changeset/spicy-turkeys-hug.md Introduced a feature that exits the build process if docker buildx is not found during self-hosted builds, improving error handling.
packages/cli-v3/package.json Updated version to 3.2.0, upgraded tinyexec dependency from ^0.2.0 to ^0.3.1, modified exports structure to specify import, and set minimum Node.js version to >=18.20.0.
packages/cli-v3/src/commands/deploy.ts Added import for tinyexec, updated deployCommand function to check for Docker Buildx, refined error handling for deployment failures, introduced a spinner for visual feedback, and improved logging and debugging statements throughout the deployment process. Added a new method _deployCommand and updated type alias for DeployCommandOptions.

Possibly related PRs

🐰 In the meadow where bunnies play,
A tool was missing, oh what a day!
With Docker Buildx now in sight,
Our builds will run, oh what delight!
Errors handled, feedback clear,
Hops of joy, let’s give a cheer! 🎉

Warning

Rate limit exceeded

@ghostdevv has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 17 minutes and 9 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Reviewing files that changed from the base of the PR and between 778e2f7 and 87acfe1.

Warning

There were issues while running some tools. Please review the errors and either fix the tool’s configuration or disable the tool if it’s a critical failure.

🔧 eslint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

packages/cli-v3/src/commands/deploy.ts

(node:30941) ESLintIgnoreWarning: The ".eslintignore" file is no longer supported. Switch to using the "ignores" property in "eslint.config.js": https://eslint.org/docs/latest/use/configure/migration-guide#ignoring-files
(Use node --trace-warnings ... to show where the warning was created)

Oops! Something went wrong! :(

ESLint: 9.15.0

ESLint couldn't find an eslint.config.(js|mjs|cjs) file.

From ESLint v9.0.0, the default configuration file is now eslint.config.js.
If you are using a .eslintrc.* file, please follow the migration guide
to update your configuration file to the new format:

https://eslint.org/docs/latest/use/configure/migration-guide

If you still have problems after following the migration guide, please stop by
https://eslint.org/chat/help to chat with the team.


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 778e2f7 and 87acfe1.

📒 Files selected for processing (1)
  • packages/cli-v3/src/commands/deploy.ts (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/cli-v3/src/commands/deploy.ts

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ 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 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.

Copy link

changeset-bot bot commented Nov 17, 2024

🦋 Changeset detected

Latest commit: 87acfe1

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 10 packages
Name Type
trigger.dev Minor
@trigger.dev/build Minor
@trigger.dev/core Minor
@trigger.dev/react-hooks Minor
@trigger.dev/sdk Minor
@trigger.dev/database Minor
@trigger.dev/otlp-importer Minor
@internal/redis-worker Patch
@internal/zod-worker Patch
@internal/testcontainers Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Outside diff range and nitpick comments (3)
.changeset/spicy-turkeys-hug.md (1)

5-5: Consider enhancing the commit message with more details

While the message follows the conventional commit format, it could be more informative by including:

  • The specific error message users will see
  • The reason for this check (--progress flag requirement)
  • The recommended solution for users

Consider expanding it to:

-feat: exit if docker buildx can't be found for self-hosted builds
+feat: exit if docker buildx can't be found for self-hosted builds
+
+Adds a prerequisite check for docker buildx when using --self-hosted flag.
+Exits with a clear error message if buildx is not installed, as it's
+required for the --progress flag to work correctly.
packages/cli-v3/src/commands/deploy.ts (2)

40-40: Consider using a more descriptive import name.

The imported function name x is not descriptive of its purpose. Consider renaming it to something more meaningful like execCommand or shellExec.

-import { x } from "tinyexec";
+import { x as execCommand } from "tinyexec";

269-276: Enhance error message with installation instructions.

The error handling is good, but the error message could be more helpful by including installation instructions for Docker buildx.

-      throw new Error("Failed to find docker buildx, please install it.");
+      throw new Error(
+        "Failed to find docker buildx. Please install it by following the instructions at: " +
+        "https://docs.docker.com/build/buildx/install/"
+      );

Also, consider including stdout/stderr in the debug log for better debugging:

-      logger.debug(`"docker buildx version" failed (${result.exitCode}):`, result);
+      logger.debug(
+        `"docker buildx version" failed (${result.exitCode}):`,
+        { ...result, stdout: result.stdout, stderr: result.stderr }
+      );
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 332854b and 778e2f7.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (3)
  • .changeset/spicy-turkeys-hug.md (1 hunks)
  • packages/cli-v3/package.json (1 hunks)
  • packages/cli-v3/src/commands/deploy.ts (2 hunks)
🔇 Additional comments (4)
.changeset/spicy-turkeys-hug.md (1)

1-3: LGTM: Appropriate version bump for new feature

The minor version bump is correctly specified and follows semantic versioning principles for feature additions.

packages/cli-v3/package.json (2)

Line range hint 134-142: LGTM! Proper ESM module structure

The exports field is correctly configured for ESM modules, including proper type definitions. This aligns with modern Node.js practices.


121-121: Verify tinyexec upgrade compatibility

The upgrade from ^0.2.0 to ^0.3.1 is used for Docker buildx checks. Let's verify the changes between versions.

packages/cli-v3/src/commands/deploy.ts (1)

269-276: LGTM! Well-integrated buildx check.

The Docker buildx check is well-placed in the deployment flow:

  • Fails fast before any resource-intensive operations
  • Logically grouped with other build prerequisites
  • Properly guarded by the selfHosted option

Copy link

pkg-pr-new bot commented Nov 18, 2024

@trigger.dev/react-hooks

pnpm add https://pkg.pr.new/triggerdotdev/trigger.dev/@trigger.dev/react-hooks@1475

@trigger.dev/sdk

pnpm add https://pkg.pr.new/triggerdotdev/trigger.dev/@trigger.dev/sdk@1475

trigger.dev

pnpm add https://pkg.pr.new/triggerdotdev/trigger.dev@1475

@trigger.dev/build

pnpm add https://pkg.pr.new/triggerdotdev/trigger.dev/@trigger.dev/build@1475

@trigger.dev/core

pnpm add https://pkg.pr.new/triggerdotdev/trigger.dev/@trigger.dev/core@1475

commit: 87acfe1

Copy link
Collaborator

@nicktrn nicktrn left a comment

Choose a reason for hiding this comment

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

Hey @ghostdevv - good spot! Thanks for this 🙏

The tinyexec upgrade should probably be fine but I'll give it a quick spin after merging.

@nicktrn nicktrn merged commit 653d974 into triggerdotdev:main Nov 18, 2024
9 checks passed
@ghostdevv ghostdevv deleted the docker-buildx-exit branch November 18, 2024 20:01
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