Skip to content

cli cold start#186

Closed
gocanto wants to merge 3 commits intomainfrom
chore/cli-docker-caching
Closed

cli cold start#186
gocanto wants to merge 3 commits intomainfrom
chore/cli-docker-caching

Conversation

@gocanto
Copy link
Copy Markdown
Collaborator

@gocanto gocanto commented Mar 21, 2026

No description provided.

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Mar 21, 2026

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: f65b1a04-8b5d-4d26-bc0e-37ddd38d8b3f

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch chore/cli-docker-caching

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

Comment @coderabbitai help to get the list of available commands and usage tips.

@gemini-code-assist
Copy link
Copy Markdown

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request focuses on enhancing the developer experience by significantly reducing the "cold start" time for the CLI application. It achieves this by implementing intelligent caching for Go build artifacts, pre-building the CLI binary within Docker, and optimizing the database startup process for the run-cli command. These changes streamline the local development workflow, making initial setup and subsequent runs faster and more efficient.

Highlights

  • Optimized CLI Startup: The make run-cli command now intelligently reuses a Docker-built CLI binary and conditionally starts the api-db service only when needed, significantly improving cold start times.
  • Go Build Caching: A new go_build_cache Docker volume has been introduced to persist Go build artifacts, reducing rebuild times for the CLI binary within the Docker environment.
  • Automated CLI Binary Building: A new build-cli-docker Makefile target was added to automate the process of building the CLI binary inside a Docker container, which is then used by run-cli.
  • Standardized Go Execution: Commands in infra/makefile/db.mk were updated to explicitly use the full path to the Go binary within the Docker container, ensuring consistent execution.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request significantly improves the make run-cli command by caching the compiled Go binary, which will speed up subsequent runs. It also adds robust health checks for the database. The implementation is solid, but I have a couple of suggestions to enhance maintainability by refactoring some duplicated code in the Makefile and removing a potentially brittle PATH override in docker-compose.yml.

Comment on lines +354 to +355
CGO_ENABLED: 1
PATH: /usr/local/go/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

Hardcoding the PATH variable can be brittle. If the Go installation path in the base image changes, this will break. Since other parts of the Makefile are being updated to use absolute paths to the go executable (e.g., /usr/local/go/bin/go), this explicit PATH definition seems redundant. It would be more robust to remove the PATH override and rely on the base image's PATH.

              CGO_ENABLED: 1

Comment on lines +108 to +118
if command -v docker >/dev/null 2>&1 && docker compose version >/dev/null 2>&1; then \
printf "Building Docker CLI binary at $(CLI_DOCKER_BINARY_CONTAINER).\n"; \
docker compose run --rm --no-deps api-runner sh -lc '/usr/local/go/bin/go build -o "$(CLI_DOCKER_BINARY_CONTAINER)" ./metal/cli/main.go' || status=$$?; \
elif command -v docker-compose >/dev/null 2>&1; then \
printf "Building Docker CLI binary at $(CLI_DOCKER_BINARY_CONTAINER).\n"; \
docker-compose run --rm --no-deps api-runner sh -lc '/usr/local/go/bin/go build -o "$(CLI_DOCKER_BINARY_CONTAINER)" ./metal/cli/main.go' || status=$$?; \
else \
printf "\n$(RED)❌ Neither 'docker compose' nor 'docker-compose' is available.$(NC)\n"; \
printf " Install Docker Compose or run the CLI locally without containers.\n\n"; \
exit 1; \
fi; \
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

This if/elif block for detecting docker compose vs docker-compose contains duplicated code. You can make this more maintainable by first determining the correct command and storing it in a variable, then using that variable to execute the build command. This avoids repeating the printf and the docker compose run... lines, similar to the pattern you've used in the run-cli target.

    compose_cmd=""; \
    if command -v docker >/dev/null 2>&1 && docker compose version >/dev/null 2>&1; then \
        compose_cmd="docker compose"; \
    elif command -v docker-compose >/dev/null 2>&1; then \
        compose_cmd="docker-compose"; \
    else \
        printf "\n$(RED)❌ Neither 'docker compose' nor 'docker-compose' is available.$(NC)\n"; \
        printf "   Install Docker Compose or run the CLI locally without containers.\n\n"; \
        exit 1; \
    fi; \
    printf "Building Docker CLI binary at $(CLI_DOCKER_BINARY_CONTAINER).\n"; \
    $$compose_cmd run --rm --no-deps api-runner sh -lc '/usr/local/go/bin/go build -o "$(CLI_DOCKER_BINARY_CONTAINER)" ./metal/cli/main.go' || status=$$?;

@gocanto gocanto closed this Mar 21, 2026
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.

1 participant