diff --git a/.github/workflows/containers.yml b/.github/workflows/containers.yml new file mode 100644 index 0000000..0086a26 --- /dev/null +++ b/.github/workflows/containers.yml @@ -0,0 +1,30 @@ +name: Build and Push Images + +on: + # schedule: + # - cron: "0 11 * * *" # Runs daily at 11 AM UTC (3 AM PST) + # push: + # tags: + # - "*" # Triggers on any new tag + workflow_dispatch: # Allows manual triggering of the workflow + +jobs: + build-and-push: + runs-on: ubuntu-latest + strategy: + matrix: + platform: [cuda, vulkan] + #platform: [intel, cuda, vulkan, musa] + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Log in to GitHub Container Registry + uses: docker/login-action@v2 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Run build-image script + run: ./docker/build-container.sh ${{ matrix.platform }} \ No newline at end of file diff --git a/docker/build-container.sh b/docker/build-container.sh new file mode 100644 index 0000000..7218060 --- /dev/null +++ b/docker/build-container.sh @@ -0,0 +1,30 @@ +#!/bin/bash + +cd $(dirname "$0") + +ARCH=$1 + +# List of allowed architectures +ALLOWED_ARCHS=("intel" "vulkan" "musa" "cuda") + +# Check if ARCH is in the allowed list +if [[ ! " ${ALLOWED_ARCHS[@]} " =~ " ${ARCH} " ]]; then + echo "Error: ARCH must be one of the following: ${ALLOWED_ARCHS[@]}" + exit 1 +fi + +# the most recent llama-swap tag +# have to strip out the 'v' due to .tar.gz file naming +LS_VER=$(curl -s https://api.github.com/repos/mostlygeek/llama-swap/releases/latest | jq -r .tag_name | sed 's/v//') +LCPP_TAG=$(curl -s -H "Authorization: Bearer $GITHUB_TOKEN" \ + "https://api.github.com/users/ggerganov/packages/container/llama.cpp/versions" \ + | jq -r --arg arch "$ARCH" '.[] | select(.metadata.container.tags[] | startswith("server-\($arch)")) | .metadata.container.tags[]' \ + | sort -r | head -n1 | awk -F '-' '{print $3}') + +CONTAINER_TAG="ghcr.io/mostlygeek/llama-swap:v${LS_VER}-${ARCH}-${LCPP_TAG}" +CONTAINER_LATEST="ghcr.io/mostlygeek/llama-swap:${ARCH}" + +echo "Building ${CONTAINER_TAG} $LS_VER" +docker build -f llama-swap.Containerfile --build-arg BASE_TAG=server-${ARCH}-${LCPP_TAG} --build-arg LS_VER=${LS_VER} -t ${CONTAINER_TAG} -t ${CONTAINER_LATEST} . +docker push ${CONTAINER_TAG} +docker push ${CONTAINER_LATEST} \ No newline at end of file diff --git a/docker/llama-swap-cuda.Containerfile b/docker/llama-swap-cuda.Containerfile new file mode 100644 index 0000000..583c989 --- /dev/null +++ b/docker/llama-swap-cuda.Containerfile @@ -0,0 +1,15 @@ +ARG BASE_TAG=server-cuda +FROM ghcr.io/ggerganov/llama.cpp:${BASE_TAG} + +# has to be after the FROM +ARG LS_VER=89 + +WORKDIR /app + +RUN \ + curl -LO https://github.com/mostlygeek/llama-swap/releases/download/v"${LS_VER}"/llama-swap_"${LS_VER}"_linux_amd64.tar.gz && \ + tar -zxf llama-swap_"${LS_VER}"_linux_amd64.tar.gz && \ + rm llama-swap_"${LS_VER}"_linux_amd64.tar.gz + + +ENTRYPOINT [ "/app/llama-swap", "--config", "/config.yaml" ] \ No newline at end of file