mirror of
https://github.com/meta-llama/llama-stack.git
synced 2025-10-21 16:07:16 +00:00
# What does this PR do? relates to #2878 We introduce a Containerfile which is used to replaced the `llama stack build` command (removal in a separate PR). ``` llama stack build --distro starter --image-type venv --run ``` is replaced by ``` llama stack list-deps starter | xargs -L1 uv pip install llama stack run starter ``` - See the updated workflow files for e2e workflow. ## Test Plan CI ``` ❯ docker build . -f docker/Dockerfile --build-arg DISTRO_NAME=starter --build-arg INSTALL_MODE=editable --tag test_starter ❯ docker run -p 8321:8321 test_starter ❯ curl http://localhost:8321/v1/chat/completions \ -H "Content-Type: application/json" \ -d '{ "model": "gpt-4o-mini", "messages": [ { "role": "user", "content": "Hello!" } ] }' ``` --- [//]: # (BEGIN SAPLING FOOTER) Stack created with [Sapling](https://sapling-scm.com). Best reviewed with [ReviewStack](https://reviewstack.dev/llamastack/llama-stack/pull/3839). * #3855 * __->__ #3839
177 lines
6.1 KiB
YAML
177 lines
6.1 KiB
YAML
name: Test Llama Stack Build
|
|
|
|
run-name: Test llama stack build
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- main
|
|
paths:
|
|
- 'llama_stack/cli/stack/build.py'
|
|
- 'llama_stack/cli/stack/_build.py'
|
|
- 'llama_stack/core/build.*'
|
|
- 'llama_stack/core/*.sh'
|
|
- '.github/workflows/providers-build.yml'
|
|
- 'llama_stack/distributions/**'
|
|
- 'pyproject.toml'
|
|
- 'containers/Containerfile'
|
|
- '.dockerignore'
|
|
|
|
pull_request:
|
|
paths:
|
|
- 'llama_stack/cli/stack/build.py'
|
|
- 'llama_stack/cli/stack/_build.py'
|
|
- 'llama_stack/core/build.*'
|
|
- 'llama_stack/core/*.sh'
|
|
- '.github/workflows/providers-build.yml'
|
|
- 'llama_stack/distributions/**'
|
|
- 'pyproject.toml'
|
|
- 'containers/Containerfile'
|
|
- '.dockerignore'
|
|
|
|
concurrency:
|
|
group: ${{ github.workflow }}-${{ github.ref == 'refs/heads/main' && github.run_id || github.ref }}
|
|
cancel-in-progress: true
|
|
|
|
jobs:
|
|
generate-matrix:
|
|
runs-on: ubuntu-latest
|
|
outputs:
|
|
distros: ${{ steps.set-matrix.outputs.distros }}
|
|
steps:
|
|
- name: Checkout repository
|
|
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
|
|
|
|
- name: Generate Distribution List
|
|
id: set-matrix
|
|
run: |
|
|
distros=$(ls llama_stack/distributions/*/*build.yaml | awk -F'/' '{print $(NF-1)}' | jq -R -s -c 'split("\n")[:-1]')
|
|
echo "distros=$distros" >> "$GITHUB_OUTPUT"
|
|
|
|
build:
|
|
needs: generate-matrix
|
|
runs-on: ubuntu-latest
|
|
strategy:
|
|
matrix:
|
|
distro: ${{ fromJson(needs.generate-matrix.outputs.distros) }}
|
|
image-type: [venv, container]
|
|
fail-fast: false # We want to run all jobs even if some fail
|
|
|
|
steps:
|
|
- name: Checkout repository
|
|
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
|
|
|
|
- name: Install dependencies
|
|
uses: ./.github/actions/setup-runner
|
|
|
|
- name: Install distribution into venv
|
|
if: matrix.image-type == 'venv'
|
|
run: |
|
|
uv run llama stack list-deps ${{ matrix.distro }} | xargs -L1 uv pip install
|
|
|
|
- name: Build container image
|
|
if: matrix.image-type == 'container'
|
|
run: |
|
|
docker build . \
|
|
-f containers/Containerfile \
|
|
--build-arg INSTALL_MODE=editable \
|
|
--build-arg DISTRO_NAME=${{ matrix.distro }} \
|
|
--tag llama-stack:${{ matrix.distro }}-ci
|
|
|
|
- name: Print dependencies in the image
|
|
if: matrix.image-type == 'venv'
|
|
run: |
|
|
uv pip list
|
|
|
|
build-single-provider:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout repository
|
|
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
|
|
|
|
- name: Install dependencies
|
|
uses: ./.github/actions/setup-runner
|
|
|
|
- name: Build a single provider
|
|
run: |
|
|
uv pip install -e .
|
|
uv run --no-sync llama stack list-deps --providers inference=remote::ollama | xargs -L1 uv pip install
|
|
build-custom-container-distribution:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout repository
|
|
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
|
|
|
|
- name: Install dependencies
|
|
uses: ./.github/actions/setup-runner
|
|
|
|
- name: Build container image
|
|
run: |
|
|
BASE_IMAGE=$(yq -r '.distribution_spec.container_image // "python:3.12-slim"' llama_stack/distributions/ci-tests/build.yaml)
|
|
docker build . \
|
|
-f containers/Containerfile \
|
|
--build-arg INSTALL_MODE=editable \
|
|
--build-arg DISTRO_NAME=ci-tests \
|
|
--build-arg BASE_IMAGE="$BASE_IMAGE" \
|
|
--build-arg RUN_CONFIG_PATH=/workspace/llama_stack/distributions/ci-tests/run.yaml \
|
|
-t llama-stack:ci-tests
|
|
|
|
- name: Inspect the container image entrypoint
|
|
run: |
|
|
IMAGE_ID=$(docker images --format "{{.Repository}}:{{.Tag}}" | head -n 1)
|
|
if [ -z "$IMAGE_ID" ]; then
|
|
echo "No image found"
|
|
exit 1
|
|
fi
|
|
entrypoint=$(docker inspect --format '{{ .Config.Entrypoint }}' $IMAGE_ID)
|
|
echo "Entrypoint: $entrypoint"
|
|
if [ "$entrypoint" != "[/usr/local/bin/llama-stack-entrypoint.sh]" ]; then
|
|
echo "Entrypoint is not correct"
|
|
exit 1
|
|
fi
|
|
|
|
build-ubi9-container-distribution:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout repository
|
|
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
|
|
|
|
- name: Install dependencies
|
|
uses: ./.github/actions/setup-runner
|
|
|
|
- name: Pin distribution to UBI9 base
|
|
run: |
|
|
yq -i '
|
|
.distribution_spec.container_image = "registry.access.redhat.com/ubi9:latest"
|
|
' llama_stack/distributions/ci-tests/build.yaml
|
|
|
|
- name: Build UBI9 container image
|
|
run: |
|
|
BASE_IMAGE=$(yq -r '.distribution_spec.container_image // "registry.access.redhat.com/ubi9:latest"' llama_stack/distributions/ci-tests/build.yaml)
|
|
docker build . \
|
|
-f containers/Containerfile \
|
|
--build-arg INSTALL_MODE=editable \
|
|
--build-arg DISTRO_NAME=ci-tests \
|
|
--build-arg BASE_IMAGE="$BASE_IMAGE" \
|
|
--build-arg RUN_CONFIG_PATH=/workspace/llama_stack/distributions/ci-tests/run.yaml \
|
|
-t llama-stack:ci-tests-ubi9
|
|
|
|
- name: Inspect UBI9 image
|
|
run: |
|
|
IMAGE_ID=$(docker images --format "{{.Repository}}:{{.Tag}}" | head -n 1)
|
|
if [ -z "$IMAGE_ID" ]; then
|
|
echo "No image found"
|
|
exit 1
|
|
fi
|
|
entrypoint=$(docker inspect --format '{{ .Config.Entrypoint }}' $IMAGE_ID)
|
|
echo "Entrypoint: $entrypoint"
|
|
if [ "$entrypoint" != "[/usr/local/bin/llama-stack-entrypoint.sh]" ]; then
|
|
echo "Entrypoint is not correct"
|
|
exit 1
|
|
fi
|
|
|
|
echo "Checking /etc/os-release in $IMAGE_ID"
|
|
docker run --rm --entrypoint sh "$IMAGE_ID" -c \
|
|
'source /etc/os-release && echo "$ID"' \
|
|
| grep -qE '^(rhel|ubi)$' \
|
|
|| { echo "Base image is not UBI 9!"; exit 1; }
|