feat: export distribution container build artifacts

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 <seb@redhat.com>
This commit is contained in:
Sébastien Han 2025-05-16 11:37:56 +02:00
parent 047303e339
commit e9bcb0e827
No known key found for this signature in database
7 changed files with 186 additions and 22 deletions

View file

@ -5,6 +5,7 @@
# the root directory of this source tree.
import argparse
import textwrap
from pathlib import Path
from llama_stack.cli.stack.utils import ImageType
from llama_stack.cli.subcommand import Subcommand
@ -82,6 +83,13 @@ the build. If not specified, currently active environment will be used if found.
help="Build a config for a list of providers and only those providers. This list is formatted like: api1=provider1,api2=provider2. Where there can be multiple providers per API.",
)
self.parser.add_argument(
"--export-dir",
type=Path,
default=None,
help="Export the build artifacts to a specified directory instead of building the container. This will create a directory containing the Dockerfile and all necessary files to build the container.",
)
def _run_stack_build_command(self, args: argparse.Namespace) -> None:
# always keep implementation completely silo-ed away from CLI so CLI
# can be fast to load and reduces dependencies