From 4dfa43a056ecc07ee6e12a2d3445ae87bf9aa977 Mon Sep 17 00:00:00 2001 From: Iulian Meghea Date: Tue, 26 May 2026 09:30:47 +0000 Subject: [PATCH] feat: add llamacpp Docker image Based on ghcr.io/ggml-org/llama.cpp:server-cuda with dstack runner prerequisites (openssh-server, sudo, dstack user). Includes MTP and Jinja autoparser support from the official llama.cpp image. --- .github/workflows/build.yml | 43 +++++++++++++++++++++++++++++++++++++ .github/workflows/ci.yml | 23 +++++++++++++++++++- README.md | 17 ++++++++++++++- images/llamacpp/Dockerfile | 14 ++++++++++++ 4 files changed, 95 insertions(+), 2 deletions(-) create mode 100644 images/llamacpp/Dockerfile diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index c3193d4..8f73d2f 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -89,6 +89,49 @@ jobs: tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} + - name: Generate artifact attestation + uses: actions/attest-build-provenance@v4 + with: + subject-name: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + subject-digest: ${{ steps.push.outputs.digest }} + push-to-registry: true + + build-llamacpp: + runs-on: ubuntu-latest + permissions: + contents: read + packages: write + attestations: write + id-token: write + steps: + - name: Checkout repository + uses: actions/checkout@v6 + + - name: Log in to the Container registry + uses: docker/login-action@v4 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Extract metadata (tags, labels) for Docker + id: meta + uses: docker/metadata-action@v6 + with: + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + tags: | + type=raw,value=llamacpp-latest + type=sha,prefix=llamacpp- + + - name: Build and push Docker image + id: push + uses: docker/build-push-action@v7 + with: + context: ./images/llamacpp + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + - name: Generate artifact attestation uses: actions/attest-build-provenance@v4 with: diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ca4bbc7..097f68c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -45,4 +45,25 @@ jobs: run: docker run --rm test-vllm-nightly id dstack - name: Verify dstack user has sudo - run: docker run --rm test-vllm-nightly sudo -n true \ No newline at end of file + run: docker run --rm test-vllm-nightly sudo -n true + + check-llamacpp: + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v6 + + - name: Build llamacpp image + run: docker build -t test-llamacpp ./images/llamacpp + + - name: Verify openssh-server installed + run: docker run --rm test-llamacpp which sshd + + - name: Verify sudo installed + run: docker run --rm test-llamacpp which sudo + + - name: Verify dstack user exists + run: docker run --rm test-llamacpp id dstack + + - name: Verify dstack user has sudo + run: docker run --rm test-llamacpp sudo -n true \ No newline at end of file diff --git a/README.md b/README.md index d028569..b2d9205 100644 --- a/README.md +++ b/README.md @@ -18,6 +18,13 @@ Same as vllm but based on `vllm/vllm-openai:nightly` — bleeding edge vLLM buil - **Tag**: `ghcr.io/plumelo/dstack-images:vllm-nightly-latest` - **What's added**: openssh-server, sudo, dstack user (uid/gid 1000), `/dstack/run` +### llamacpp + +Based on `ghcr.io/ggml-org/llama.cpp:server-cuda` with pre-installed dstack runner prerequisites. Includes MTP (multi-token prediction) support and the Jinja-based autoparser for automatic tool call detection. + +- **Tag**: `ghcr.io/plumelo/dstack-images:llamacpp-latest` +- **What's added**: openssh-server, sudo, dstack user (uid/gid 1000), `/dstack/run` + ## Usage ```yaml @@ -36,6 +43,14 @@ image: ghcr.io/plumelo/dstack-images:vllm-nightly-latest commands: - | vllm serve $MODEL_ID --host 0.0.0.0 --port 8000 ... + +# llama.cpp +type: service +name: my-llamacpp +image: ghcr.io/plumelo/dstack-images:llamacpp-latest +commands: + - | + /app/llama-server --hf-repo $MODEL_REPO --hf-file $MODEL_FILE --port 8000 ... ``` ## Cold start improvement @@ -47,5 +62,5 @@ commands: ## CI/CD -- **Push to main**: builds and pushes both image tags + SHA tags +- **Push to main**: builds and pushes all image tags + SHA tags - **PR**: builds and runs verification checks per image diff --git a/images/llamacpp/Dockerfile b/images/llamacpp/Dockerfile new file mode 100644 index 0000000..57724f8 --- /dev/null +++ b/images/llamacpp/Dockerfile @@ -0,0 +1,14 @@ +FROM ghcr.io/ggml-org/llama.cpp:server-cuda + +RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y \ + openssh-server sudo \ + && sed -i "s/.*PasswordAuthentication.*/PasswordAuthentication no/g" /etc/ssh/sshd_config \ + && mkdir /run/sshd \ + && rm -f /etc/ssh/ssh_host_* \ + && groupadd -g 1000 dstack \ + && useradd -u 1000 -g 1000 -G sudo -s /bin/bash -m dstack \ + && echo 'dstack ALL=(ALL) NOPASSWD: ALL' > /etc/sudoers.d/dstack \ + && mkdir -p /dstack/run && chmod a+rwx /dstack/run \ + && rm -rf /var/lib/apt/lists/* + +EXPOSE 8000 \ No newline at end of file