# Define the CANN base image for easier version updates later
ARG CHIP_TYPE=910b
ARG CANN_BASE_IMAGE=quay.io/ascend/cann:8.5.0-${CHIP_TYPE}-openeuler24.03-py3.11
+ARG BUILD_DATE=N/A
+ARG APP_VERSION=N/A
+ARG APP_REVISION=N/A
# ==============================================================================
# BUILD STAGE
# ==============================================================================
FROM ${CANN_BASE_IMAGE} AS base
+ARG BUILD_DATE=N/A
+ARG APP_VERSION=N/A
+ARG APP_REVISION=N/A
+ARG IMAGE_URL=https://github.com/ggml-org/llama.cpp
+ARG IMAGE_SOURCE=https://github.com/ggml-org/llama.cpp
+LABEL org.opencontainers.image.created=$BUILD_DATE \
+ org.opencontainers.image.version=$APP_VERSION \
+ org.opencontainers.image.revision=$APP_REVISION \
+ org.opencontainers.image.title="llama.cpp" \
+ org.opencontainers.image.description="LLM inference in C/C++" \
+ org.opencontainers.image.url=$IMAGE_URL \
+ org.opencontainers.image.source=$IMAGE_SOURCE
+
# -- Install runtime dependencies --
RUN yum install -y libgomp curl && \
yum clean all && \
ARG UBUNTU_VERSION=24.04
+ARG BUILD_DATE=N/A
+ARG APP_VERSION=N/A
+ARG APP_REVISION=N/A
FROM ubuntu:$UBUNTU_VERSION AS build
## Base image
FROM ubuntu:$UBUNTU_VERSION AS base
+ARG BUILD_DATE=N/A
+ARG APP_VERSION=N/A
+ARG APP_REVISION=N/A
+ARG IMAGE_URL=https://github.com/ggml-org/llama.cpp
+ARG IMAGE_SOURCE=https://github.com/ggml-org/llama.cpp
+LABEL org.opencontainers.image.created=$BUILD_DATE \
+ org.opencontainers.image.version=$APP_VERSION \
+ org.opencontainers.image.revision=$APP_REVISION \
+ org.opencontainers.image.title="llama.cpp" \
+ org.opencontainers.image.description="LLM inference in C/C++" \
+ org.opencontainers.image.url=$IMAGE_URL \
+ org.opencontainers.image.source=$IMAGE_SOURCE
+
RUN apt-get update \
&& apt-get install -y libgomp1 curl \
&& apt autoremove -y \
ARG BASE_CUDA_RUN_CONTAINER=nvidia/cuda:${CUDA_VERSION}-runtime-ubuntu${UBUNTU_VERSION}
+ARG BUILD_DATE=N/A
+ARG APP_VERSION=N/A
+ARG APP_REVISION=N/A
+
FROM ${BASE_CUDA_DEV_CONTAINER} AS build
# CUDA architecture to build for (defaults to all supported archs)
## Base image
FROM ${BASE_CUDA_RUN_CONTAINER} AS base
+ARG BUILD_DATE=N/A
+ARG APP_VERSION=N/A
+ARG APP_REVISION=N/A
+ARG IMAGE_URL=https://github.com/ggml-org/llama.cpp
+ARG IMAGE_SOURCE=https://github.com/ggml-org/llama.cpp
+LABEL org.opencontainers.image.created=$BUILD_DATE \
+ org.opencontainers.image.version=$APP_VERSION \
+ org.opencontainers.image.revision=$APP_REVISION \
+ org.opencontainers.image.title="llama.cpp" \
+ org.opencontainers.image.description="LLM inference in C/C++" \
+ org.opencontainers.image.url=$IMAGE_URL \
+ org.opencontainers.image.source=$IMAGE_SOURCE
+
RUN apt-get update \
&& apt-get install -y libgomp1 curl \
&& apt autoremove -y \
ARG ONEAPI_VERSION=2025.3.3-0-devel-ubuntu24.04
+ARG BUILD_DATE=N/A
+ARG APP_VERSION=N/A
+ARG APP_REVISION=N/A
## Build Image
FROM intel/deep-learning-essentials:$ONEAPI_VERSION AS base
+ARG BUILD_DATE=N/A
+ARG APP_VERSION=N/A
+ARG APP_REVISION=N/A
+ARG IMAGE_URL=https://github.com/ggml-org/llama.cpp
+ARG IMAGE_SOURCE=https://github.com/ggml-org/llama.cpp
+LABEL org.opencontainers.image.created=$BUILD_DATE \
+ org.opencontainers.image.version=$APP_VERSION \
+ org.opencontainers.image.revision=$APP_REVISION \
+ org.opencontainers.image.title="llama.cpp" \
+ org.opencontainers.image.description="LLM inference in C/C++" \
+ org.opencontainers.image.url=$IMAGE_URL \
+ org.opencontainers.image.source=$IMAGE_SOURCE
+
ARG IGC_VERSION=v2.20.5
ARG IGC_VERSION_FULL=2_2.20.5+19972
ARG COMPUTE_RUNTIME_VERSION=25.40.35563.10
ARG ASCEND_VERSION=8.5.0-910b-openeuler22.03-py3.10
+ARG BUILD_DATE=N/A
+ARG APP_VERSION=N/A
+ARG APP_REVISION=N/A
FROM ascendai/cann:$ASCEND_VERSION AS build
# TODO: use image with NNRT
FROM ascendai/cann:$ASCEND_VERSION AS runtime
+
+ARG BUILD_DATE=N/A
+ARG APP_VERSION=N/A
+ARG APP_REVISION=N/A
+ARG IMAGE_URL=https://github.com/ggml-org/llama.cpp
+ARG IMAGE_SOURCE=https://github.com/ggml-org/llama.cpp
+LABEL org.opencontainers.image.created=$BUILD_DATE \
+ org.opencontainers.image.version=$APP_VERSION \
+ org.opencontainers.image.revision=$APP_REVISION \
+ org.opencontainers.image.title="llama.cpp" \
+ org.opencontainers.image.description="LLM inference in C/C++" \
+ org.opencontainers.image.url=$IMAGE_URL \
+ org.opencontainers.image.source=$IMAGE_SOURCE
+
COPY --from=build /app/build/bin/llama-cli /app/build/bin/llama-completion /
ENV LC_ALL=C.utf8
ARG BASE_MUSA_RUN_CONTAINER=mthreads/musa:${MUSA_VERSION}-runtime-ubuntu${UBUNTU_VERSION}-amd64
+ARG BUILD_DATE=N/A
+ARG APP_VERSION=N/A
+ARG APP_REVISION=N/A
+
FROM ${BASE_MUSA_DEV_CONTAINER} AS build
# MUSA architecture to build for (defaults to all supported archs)
## Base image
FROM ${BASE_MUSA_RUN_CONTAINER} AS base
+ARG BUILD_DATE=N/A
+ARG APP_VERSION=N/A
+ARG APP_REVISION=N/A
+ARG IMAGE_URL=https://github.com/ggml-org/llama.cpp
+ARG IMAGE_SOURCE=https://github.com/ggml-org/llama.cpp
+LABEL org.opencontainers.image.created=$BUILD_DATE \
+ org.opencontainers.image.version=$APP_VERSION \
+ org.opencontainers.image.revision=$APP_REVISION \
+ org.opencontainers.image.title="llama.cpp" \
+ org.opencontainers.image.description="LLM inference in C/C++" \
+ org.opencontainers.image.url=$IMAGE_URL \
+ org.opencontainers.image.source=$IMAGE_SOURCE
+
RUN apt-get update \
&& apt-get install -y libgomp1 curl \
&& apt autoremove -y \
ARG http_proxy=
ARG https_proxy=
+ARG BUILD_DATE=N/A
+ARG APP_VERSION=N/A
+ARG APP_REVISION=N/A
+
## Build Image
FROM ubuntu:${UBUNTU_VERSION} AS build
# Pass proxy args to runtime stage
ARG http_proxy
ARG https_proxy
+ARG BUILD_DATE=N/A
+ARG APP_VERSION=N/A
+ARG APP_REVISION=N/A
+ARG IMAGE_URL=https://github.com/ggml-org/llama.cpp
+ARG IMAGE_SOURCE=https://github.com/ggml-org/llama.cpp
+LABEL org.opencontainers.image.created=$BUILD_DATE \
+ org.opencontainers.image.version=$APP_VERSION \
+ org.opencontainers.image.revision=$APP_REVISION \
+ org.opencontainers.image.title="llama.cpp" \
+ org.opencontainers.image.description="LLM inference in C/C++" \
+ org.opencontainers.image.url=$IMAGE_URL \
+ org.opencontainers.image.source=$IMAGE_SOURCE
RUN apt-get update \
&& apt-get install -y libgomp1 libtbb12 curl wget ocl-icd-libopencl1 \
# Target the ROCm build image
ARG BASE_ROCM_DEV_CONTAINER=rocm/dev-ubuntu-${UBUNTU_VERSION}:${ROCM_VERSION}-complete
+ARG BUILD_DATE=N/A
+ARG APP_VERSION=N/A
+ARG APP_REVISION=N/A
+
### Build image
FROM ${BASE_ROCM_DEV_CONTAINER} AS build
## Base image
FROM ${BASE_ROCM_DEV_CONTAINER} AS base
+ARG BUILD_DATE=N/A
+ARG APP_VERSION=N/A
+ARG APP_REVISION=N/A
+ARG IMAGE_URL=https://github.com/ggml-org/llama.cpp
+ARG IMAGE_SOURCE=https://github.com/ggml-org/llama.cpp
+LABEL org.opencontainers.image.created=$BUILD_DATE \
+ org.opencontainers.image.version=$APP_VERSION \
+ org.opencontainers.image.revision=$APP_REVISION \
+ org.opencontainers.image.title="llama.cpp" \
+ org.opencontainers.image.description="LLM inference in C/C++" \
+ org.opencontainers.image.url=$IMAGE_URL \
+ org.opencontainers.image.source=$IMAGE_SOURCE
+
RUN apt-get update \
&& apt-get install -y libgomp1 curl \
&& apt autoremove -y \
ARG GCC_VERSION=15.2.0
ARG UBUNTU_VERSION=24.04
+ARG BUILD_DATE=N/A
+ARG APP_VERSION=N/A
+ARG APP_REVISION=N/A
### Build Llama.cpp stage
FROM gcc:${GCC_VERSION} AS build
### Base image
FROM ubuntu:${UBUNTU_VERSION} AS base
+ARG BUILD_DATE=N/A
+ARG APP_VERSION=N/A
+ARG APP_REVISION=N/A
+ARG IMAGE_URL=https://github.com/ggml-org/llama.cpp
+ARG IMAGE_SOURCE=https://github.com/ggml-org/llama.cpp
+LABEL org.opencontainers.image.created=$BUILD_DATE \
+ org.opencontainers.image.version=$APP_VERSION \
+ org.opencontainers.image.revision=$APP_REVISION \
+ org.opencontainers.image.title="llama.cpp" \
+ org.opencontainers.image.description="LLM inference in C/C++" \
+ org.opencontainers.image.url=$IMAGE_URL \
+ org.opencontainers.image.source=$IMAGE_SOURCE
+
RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \
--mount=type=cache,target=/var/lib/apt/lists,sharing=locked \
apt update -y && \
ARG UBUNTU_VERSION=26.04
+ARG BUILD_DATE=N/A
+ARG APP_VERSION=N/A
+ARG APP_REVISION=N/A
FROM ubuntu:$UBUNTU_VERSION AS build
## Base image
FROM ubuntu:$UBUNTU_VERSION AS base
+ARG BUILD_DATE=N/A
+ARG APP_VERSION=N/A
+ARG APP_REVISION=N/A
+ARG IMAGE_URL=https://github.com/ggml-org/llama.cpp
+ARG IMAGE_SOURCE=https://github.com/ggml-org/llama.cpp
+LABEL org.opencontainers.image.created=$BUILD_DATE \
+ org.opencontainers.image.version=$APP_VERSION \
+ org.opencontainers.image.revision=$APP_REVISION \
+ org.opencontainers.image.title="llama.cpp" \
+ org.opencontainers.image.description="LLM inference in C/C++" \
+ org.opencontainers.image.url=$IMAGE_URL \
+ org.opencontainers.image.source=$IMAGE_SOURCE
+
RUN apt-get update \
&& apt-get install -y libgomp1 curl libvulkan1 mesa-vulkan-drivers \
libglvnd0 libgl1 libglx0 libegl1 libgles2 \
on:
workflow_dispatch: # allows manual triggering
+ inputs:
+ skip_s390x:
+ description: "Skip the s390x build target (useful for fast test runs that do not need the IBM Z runner)"
+ type: boolean
+ default: false
schedule:
# Rebuild daily rather than on every push because it is expensive
- cron: '12 4 * * *'
- name: Generate build and merge matrices
id: matrices
shell: bash
+ env:
+ SKIP_S390X: ${{ inputs.skip_s390x || 'false' }}
run: |
set -euo pipefail
]
JSON
+ if [ "${SKIP_S390X}" = "true" ]; then
+ jq 'map(select(.platforms != "linux/s390x"))' build-matrix.json > build-matrix.json.tmp
+ mv build-matrix.json.tmp build-matrix.json
+ fi
+
BUILD_MATRIX="$(jq -c . build-matrix.json)"
MERGE_MATRIX="$(jq -c '
reduce .[] as $entry ({}; .[$entry.tag] |= (
config: ${{ fromJSON(needs.prepare_matrices.outputs.build_matrix) }}
steps:
- name: Check out the repo
+ id: checkout
uses: actions/checkout@v6
with:
fetch-depth: 0
env:
GITHUB_REPOSITORY_OWNER: '${{ github.repository_owner }}'
+ - name: Get build date
+ id: build_date
+ run: echo "date=$(date -u +"%Y-%m-%dT%H:%M:%SZ")" >> $GITHUB_OUTPUT
+
- name: Free Disk Space (Ubuntu)
if: ${{ matrix.config.free_disk_space == true }}
uses: ggml-org/free-disk-space@v1.3.1
with:
context: .
platforms: ${{ matrix.config.platforms }}
- outputs: type=image,name=${{ steps.meta.outputs.image_repo }},push-by-digest=true,name-canonical=true,push=true
+ outputs: type=image,name=${{ steps.meta.outputs.image_repo }},push-by-digest=true,name-canonical=true,push=true,oci-mediatypes=true
file: ${{ matrix.config.dockerfile }}
target: full
provenance: false
build-args: |
+ BUILD_DATE=${{ steps.build_date.outputs.date }}
+ APP_VERSION=${{ needs.create_tag.outputs.source_tag }}
+ APP_REVISION=${{ steps.checkout.outputs.commit }}
+ IMAGE_URL=${{ github.server_url }}/${{ github.repository }}
+ IMAGE_SOURCE=${{ github.server_url }}/${{ github.repository }}
${{ matrix.config.ubuntu_version && format('UBUNTU_VERSION={0}', matrix.config.ubuntu_version) || '' }}
${{ matrix.config.cuda_version && format('CUDA_VERSION={0}', matrix.config.cuda_version) || '' }}
+ annotations: |
+ manifest:org.opencontainers.image.created=${{ steps.build_date.outputs.date }}
+ manifest:org.opencontainers.image.version=${{ needs.create_tag.outputs.source_tag }}
+ manifest:org.opencontainers.image.revision=${{ steps.checkout.outputs.commit }}
+ manifest:org.opencontainers.image.title=llama.cpp
+ manifest:org.opencontainers.image.description=LLM inference in C/C++
+ manifest:org.opencontainers.image.url=${{ github.server_url }}/${{ github.repository }}
+ manifest:org.opencontainers.image.source=${{ github.server_url }}/${{ github.repository }}
# using github experimental cache
#cache-from: type=gha
#cache-to: type=gha,mode=max
with:
context: .
platforms: ${{ matrix.config.platforms }}
- outputs: type=image,name=${{ steps.meta.outputs.image_repo }},push-by-digest=true,name-canonical=true,push=true
+ outputs: type=image,name=${{ steps.meta.outputs.image_repo }},push-by-digest=true,name-canonical=true,push=true,oci-mediatypes=true
file: ${{ matrix.config.dockerfile }}
target: light
provenance: false
build-args: |
+ BUILD_DATE=${{ steps.build_date.outputs.date }}
+ APP_VERSION=${{ needs.create_tag.outputs.source_tag }}
+ APP_REVISION=${{ steps.checkout.outputs.commit }}
+ IMAGE_URL=${{ github.server_url }}/${{ github.repository }}
+ IMAGE_SOURCE=${{ github.server_url }}/${{ github.repository }}
${{ matrix.config.ubuntu_version && format('UBUNTU_VERSION={0}', matrix.config.ubuntu_version) || '' }}
${{ matrix.config.cuda_version && format('CUDA_VERSION={0}', matrix.config.cuda_version) || '' }}
+ annotations: |
+ manifest:org.opencontainers.image.created=${{ steps.build_date.outputs.date }}
+ manifest:org.opencontainers.image.version=${{ needs.create_tag.outputs.source_tag }}
+ manifest:org.opencontainers.image.revision=${{ steps.checkout.outputs.commit }}
+ manifest:org.opencontainers.image.title=llama.cpp
+ manifest:org.opencontainers.image.description=LLM inference in C/C++
+ manifest:org.opencontainers.image.url=${{ github.server_url }}/${{ github.repository }}
+ manifest:org.opencontainers.image.source=${{ github.server_url }}/${{ github.repository }}
# using github experimental cache
#cache-from: type=gha
#cache-to: type=gha,mode=max
with:
context: .
platforms: ${{ matrix.config.platforms }}
- outputs: type=image,name=${{ steps.meta.outputs.image_repo }},push-by-digest=true,name-canonical=true,push=true
+ outputs: type=image,name=${{ steps.meta.outputs.image_repo }},push-by-digest=true,name-canonical=true,push=true,oci-mediatypes=true
file: ${{ matrix.config.dockerfile }}
target: server
provenance: false
build-args: |
+ BUILD_DATE=${{ steps.build_date.outputs.date }}
+ APP_VERSION=${{ needs.create_tag.outputs.source_tag }}
+ APP_REVISION=${{ steps.checkout.outputs.commit }}
+ IMAGE_URL=${{ github.server_url }}/${{ github.repository }}
+ IMAGE_SOURCE=${{ github.server_url }}/${{ github.repository }}
${{ matrix.config.ubuntu_version && format('UBUNTU_VERSION={0}', matrix.config.ubuntu_version) || '' }}
${{ matrix.config.cuda_version && format('CUDA_VERSION={0}', matrix.config.cuda_version) || '' }}
+ annotations: |
+ manifest:org.opencontainers.image.created=${{ steps.build_date.outputs.date }}
+ manifest:org.opencontainers.image.version=${{ needs.create_tag.outputs.source_tag }}
+ manifest:org.opencontainers.image.revision=${{ steps.checkout.outputs.commit }}
+ manifest:org.opencontainers.image.title=llama.cpp
+ manifest:org.opencontainers.image.description=LLM inference in C/C++
+ manifest:org.opencontainers.image.url=${{ github.server_url }}/${{ github.repository }}
+ manifest:org.opencontainers.image.source=${{ github.server_url }}/${{ github.repository }}
# using github experimental cache
#cache-from: type=gha
#cache-to: type=gha,mode=max
steps:
- name: Check out the repo
+ id: checkout
uses: actions/checkout@v6
with:
fetch-depth: 0
+ - name: Get build date
+ id: build_date
+ run: echo "date=$(date -u +"%Y-%m-%dT%H:%M:%SZ")" >> $GITHUB_OUTPUT
+
- name: Download digest metadata
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8
with:
IMAGE_REPO="ghcr.io/${REPO_OWNER}/${REPO_NAME}"
PREFIX="${IMAGE_REPO}:"
SRC_TAG="${{ needs.create_tag.outputs.source_tag }}"
+ BUILD_DATE="${{ steps.build_date.outputs.date }}"
+ COMMIT_SHA="${{ steps.checkout.outputs.commit }}"
TAGS="${{ matrix.config.tag }}"
ARCHES="${{ matrix.config.arches }}"
DIGEST_GLOB="/tmp/digests/*.tsv"
refs+=("${IMAGE_REPO}@${digest}")
done
+ local annotations=(
+ --annotation "index:org.opencontainers.image.created=${BUILD_DATE}"
+ --annotation "index:org.opencontainers.image.version=${SRC_TAG}"
+ --annotation "index:org.opencontainers.image.revision=${COMMIT_SHA}"
+ --annotation "index:org.opencontainers.image.title=llama.cpp"
+ --annotation "index:org.opencontainers.image.description=LLM inference in C/C++"
+ --annotation "index:org.opencontainers.image.url=${{ github.server_url }}/${{ github.repository }}"
+ --annotation "index:org.opencontainers.image.source=${{ github.server_url }}/${{ github.repository }}"
+ )
+
echo "Creating ${merged_tag} from ${refs[*]}"
- docker buildx imagetools create --tag "${merged_tag}" "${refs[@]}"
+ docker buildx imagetools create "${annotations[@]}" --tag "${merged_tag}" "${refs[@]}"
echo "Creating ${merged_versioned_tag} from ${refs[*]}"
- docker buildx imagetools create --tag "${merged_versioned_tag}" "${refs[@]}"
+ docker buildx imagetools create "${annotations[@]}" --tag "${merged_versioned_tag}" "${refs[@]}"
}
for tag in $TAGS; do