Skip to content

feat: export distribution container build artifacts #2186

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

leseb
Copy link
Collaborator

@leseb leseb commented May 16, 2025

What does this PR do?

Add a new --export-dir flag to the llama stack build command that allows users to export container build artifacts to a specified directory instead of building the container directly. This feature is useful for:

  • Building containers in different environments
  • Sharing build configurations
  • Customizing the build process

The exported tarball includes:

  • Containerfile (Dockerfile)
  • Run configuration file (if building from config)
  • External provider files (if specified)
  • Build script for assistance

The tarball is named with a timestamp for uniqueness: _.tar.gz

Documentation has been updated in building_distro.md to reflect this new functionality as well as integration tests.

Test Plan

llama stack build --config llama_stack/templates/starter/build.yaml --export-dir exports
cd exports
tar xzvf <tarball>
docker build -t dist .

@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Meta Open Source bot. label May 16, 2025
@leseb leseb force-pushed the build-export branch 6 times, most recently from dcf3c02 to c151c80 Compare May 16, 2025 10:19
Add a new --export-dir flag to the `llama stack build` command that
allows users to export container build artifacts to a specified
directory instead of building the container directly. This feature is
useful for:

- Building containers in different environments
- Sharing build configurations
- Customizing the build process

The exported tarball includes:
- Containerfile (Dockerfile)
- Run configuration file (if building from config)
- External provider files (if specified)
- Build script for assistance

The tarball is named with a timestamp for uniqueness: <distro-name>_<timestamp>.tar.gz

Documentation has been updated in building_distro.md to reflect this new
functionality as well as integration tests.

Signed-off-by: Sébastien Han <[email protected]>
@@ -270,6 +273,50 @@ printf "Containerfile created successfully in %s/Containerfile\n\n" "$TEMP_DIR"
cat "$TEMP_DIR"/Containerfile
printf "\n"

# If export_dir is specified, copy all necessary files and exit
Copy link
Contributor

Choose a reason for hiding this comment

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

this script is getting very large. I think at the very least we can make this section into a function perhaps?

# Create the archive with all files
echo "Creating tarball with the following files:"
echo "- Containerfile"
[ -n "$run_config" ] && echo "- run.yaml"
Copy link
Contributor

Choose a reason for hiding this comment

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

nice one liners

edit: although the conditionals get repeated. can you add the echo as you are building the tar_cmd?

;;
*)
# Check if argument is a valid directory path (export_dir) or special_pip_deps
if [[ "$1" == *" "* ]] || ! mkdir -p "$1" 2>/dev/null; then
Copy link
Contributor

Choose a reason for hiding this comment

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

hm what is this? this looks very dangerous. why are we doing mkdir -p for checking?!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Meta Open Source bot.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants