From d97bcaf62524aef93a2cfe4f2eba14bac0ee97ad Mon Sep 17 00:00:00 2001 From: Xi Yan Date: Tue, 14 Jan 2025 14:39:37 -0800 Subject: [PATCH] test --- .github/workflows/publish-to-docker.yml | 30 +++++++++++++++++++++ llama_stack/distribution/build.py | 2 +- llama_stack/distribution/build_container.sh | 14 +++++++--- 3 files changed, 41 insertions(+), 5 deletions(-) create mode 100644 .github/workflows/publish-to-docker.yml diff --git a/.github/workflows/publish-to-docker.yml b/.github/workflows/publish-to-docker.yml new file mode 100644 index 000000000..6002758c7 --- /dev/null +++ b/.github/workflows/publish-to-docker.yml @@ -0,0 +1,30 @@ +name: Docker Build and Publish + +on: + push + +jobs: + build-and-push: + runs-on: ubuntu-latest + permissions: + contents: read + packages: write + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Log in to the Container registry + uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + + - name: Custom build docker image + run: | + pip install --no-cache --index-url https://pypi.org/simple/ --extra-index-url https://test.pypi.org/simple/ llama-stack==0.0.63.dev20250114 + TESTPYPI_VERSION=0.0.63.dev20250114 llama stack build --template ollama --image-type docker + docker images diff --git a/llama_stack/distribution/build.py b/llama_stack/distribution/build.py index 4f63be383..3bec25b94 100644 --- a/llama_stack/distribution/build.py +++ b/llama_stack/distribution/build.py @@ -123,7 +123,7 @@ def build_image( str(build_file_path), str(BUILDS_BASE_DIR / ImageType.docker.value), " ".join(normal_deps), - dockerfile_only, + str(dockerfile_only), ] elif build_config.image_type == ImageType.conda.value: script = ( diff --git a/llama_stack/distribution/build_container.sh b/llama_stack/distribution/build_container.sh index bde549af3..6b76646f7 100755 --- a/llama_stack/distribution/build_container.sh +++ b/llama_stack/distribution/build_container.sh @@ -18,7 +18,7 @@ if [ "$#" -lt 4 ]; then exit 1 fi -special_pip_deps="$6" +special_pip_deps="$7" set -euo pipefail @@ -28,7 +28,7 @@ docker_base=$2 build_file_path=$3 host_build_dir=$4 pip_dependencies=$5 -dockerfile_only=$7 +dockerfile_only=$6 # Define color codes RED='\033[0;31m' @@ -147,8 +147,6 @@ ENTRYPOINT ["python", "-m", "llama_stack.distribution.server.server", "--templat EOF printf "Dockerfile created successfully in $TEMP_DIR/Dockerfile\n\n" -cp "$TEMP_DIR/Dockerfile" "./Dockerfile" -printf "Dockerfile saved to ./Dockerfile\n\n" cat $TEMP_DIR/Dockerfile printf "\n" @@ -178,6 +176,14 @@ fi # Add version tag to image name image_tag="$image_name:$version_tag" +if [ "$dockerfile_only" = "True" ]; then + echo "Skipping docker build as dockerfile_only=True" + dockerfile_name="Dockerfile.${image_tag}" + cp "$TEMP_DIR/Dockerfile" "./${dockerfile_name}" + printf "Dockerfile saved to ./${dockerfile_name}\n\n" + exit 0 +fi + # Detect platform architecture ARCH=$(uname -m) if [ -n "$BUILD_PLATFORM" ]; then