Skip to content

Commit 4b1a944

Browse files
committed
ci: publish aligned Docker images
1 parent df03947 commit 4b1a944

3 files changed

Lines changed: 88 additions & 22 deletions

File tree

.devops/cuda.Dockerfile

Lines changed: 33 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1-
ARG UBUNTU_VERSION=24.04
1+
# syntax=docker/dockerfile:1.7
2+
3+
ARG UBUNTU_VERSION=22.04
24
# This needs to generally match the container host's environment.
3-
ARG CUDA_VERSION=12.8.1
5+
ARG CUDA_VERSION=12.4.1
46
# Target the CUDA build image
57
ARG BASE_CUDA_DEV_CONTAINER=nvidia/cuda:${CUDA_VERSION}-devel-ubuntu${UBUNTU_VERSION}
68

@@ -14,21 +16,44 @@ FROM ${BASE_CUDA_DEV_CONTAINER} AS build
1416

1517
# CUDA architecture to build for (defaults to all supported archs)
1618
ARG CUDA_DOCKER_ARCH=default
19+
# CMake target to build. Keep "all" for full/local images; CI server images set this to llama-server.
20+
ARG CUDA_BUILD_TARGET=all
1721

18-
RUN apt-get update && \
19-
apt-get install -y gcc-14 g++-14 build-essential cmake python3 python3-pip git libssl-dev libgomp1
22+
RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \
23+
--mount=type=cache,target=/var/lib/apt/lists,sharing=locked \
24+
apt-get update && \
25+
apt-get install -y --no-install-recommends build-essential cmake ninja-build ccache python3 python3-pip git libssl-dev libgomp1 && \
26+
rm -rf /var/lib/apt/lists/*
2027

21-
ENV CC=gcc-14 CXX=g++-14 CUDAHOSTCXX=g++-14
28+
ENV CC=gcc CXX=g++ CUDAHOSTCXX=g++ CCACHE_SLOPPINESS=time_macros CCACHE_MAXSIZE=2G
2229

2330
WORKDIR /app
2431

2532
COPY . .
2633

27-
RUN if [ "${CUDA_DOCKER_ARCH}" != "default" ]; then \
34+
RUN --mount=type=cache,target=/root/.ccache \
35+
if [ "${CUDA_DOCKER_ARCH}" != "default" ]; then \
2836
export CMAKE_ARGS="-DCMAKE_CUDA_ARCHITECTURES=${CUDA_DOCKER_ARCH}"; \
2937
fi && \
30-
cmake -B build -DGGML_NATIVE=OFF -DGGML_CUDA=ON -DGGML_BACKEND_DL=ON -DGGML_CPU_ALL_VARIANTS=ON -DLLAMA_BUILD_TESTS=OFF ${CMAKE_ARGS} -DCMAKE_EXE_LINKER_FLAGS=-Wl,--allow-shlib-undefined . && \
31-
cmake --build build --config Release -j$(nproc)
38+
cmake -S . -B build -G Ninja \
39+
-DGGML_NATIVE=OFF \
40+
-DGGML_CUDA=ON \
41+
-DGGML_CUDA_FA=ON \
42+
-DGGML_CUDA_FA_ALL_QUANTS=ON \
43+
-DGGML_BACKEND_DL=ON \
44+
-DGGML_CPU_ALL_VARIANTS=ON \
45+
-DLLAMA_BUILD_TESTS=OFF \
46+
-DCMAKE_C_COMPILER_LAUNCHER=ccache \
47+
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache \
48+
-DCMAKE_CUDA_COMPILER_LAUNCHER=ccache \
49+
${CMAKE_ARGS} \
50+
-DCMAKE_EXE_LINKER_FLAGS=-Wl,--allow-shlib-undefined && \
51+
if [ "${CUDA_BUILD_TARGET}" = "all" ]; then \
52+
cmake --build build --config Release -j"$(nproc)"; \
53+
else \
54+
cmake --build build --config Release -j"$(nproc)" --target "${CUDA_BUILD_TARGET}"; \
55+
fi && \
56+
ccache --show-stats
3257

3358
RUN mkdir -p /app/lib && \
3459
find build -name "*.so*" -exec cp -P {} /app/lib \;

.github/workflows/docker.yml

Lines changed: 50 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,14 @@ on:
44
push:
55
branches:
66
- main
7+
- "v*"
78
tags:
89
- "v*"
10+
workflow_dispatch:
911

1012
concurrency:
1113
group: ${{ github.workflow }}-${{ github.ref }}
12-
cancel-in-progress: false
14+
cancel-in-progress: ${{ github.ref_type == 'branch' }}
1315

1416
permissions:
1517
contents: read
@@ -22,7 +24,10 @@ jobs:
2224
outputs:
2325
image_repo: ${{ steps.meta.outputs.image_repo }}
2426
version: ${{ steps.meta.outputs.version }}
27+
ref_name_safe: ${{ steps.meta.outputs.ref_name_safe }}
28+
short_sha: ${{ steps.meta.outputs.short_sha }}
2529
publish: ${{ steps.meta.outputs.publish }}
30+
release: ${{ steps.meta.outputs.release }}
2631
steps:
2732
- name: Check out the repo
2833
uses: actions/checkout@v6
@@ -36,34 +41,51 @@ jobs:
3641
set -euo pipefail
3742
3843
publish="false"
44+
release="false"
3945
short_sha="${GITHUB_SHA::12}"
4046
exact_tag="$(git tag --points-at "${GITHUB_SHA}" --list 'v*' | sort -V | tail -n 1 || true)"
47+
ref_name_safe="$(printf '%s' "${GITHUB_REF_NAME}" | tr '[:upper:]' '[:lower:]' | sed -E 's#[^a-z0-9_.-]+#-#g; s#^[.-]+##; s#[.-]+$##')"
48+
if [[ -z "${ref_name_safe}" ]]; then
49+
ref_name_safe="${short_sha}"
50+
fi
4151
42-
if [[ "${GITHUB_EVENT_NAME}" == "push" && "${GITHUB_REF}" == refs/tags/v* ]]; then
52+
if [[ "${GITHUB_REF}" == refs/tags/v* ]]; then
4353
version="${GITHUB_REF_NAME}"
4454
git fetch origin +refs/heads/main:refs/remotes/origin/main --no-tags
4555
if git merge-base --is-ancestor "${GITHUB_SHA}" refs/remotes/origin/main; then
4656
publish="true"
57+
release="true"
4758
else
4859
echo "Tag ${GITHUB_REF_NAME} is not on origin/main; skipping Docker publish."
4960
fi
50-
elif [[ "${GITHUB_EVENT_NAME}" == "push" && "${GITHUB_REF}" == "refs/heads/main" && -n "${exact_tag}" ]]; then
61+
elif [[ "${GITHUB_REF}" == "refs/heads/main" && -n "${exact_tag}" ]]; then
5162
version="${exact_tag}"
5263
publish="true"
64+
release="true"
65+
elif [[ "${GITHUB_REF}" == "refs/heads/main" || "${GITHUB_REF}" == refs/heads/v* ]]; then
66+
version="${ref_name_safe}-${short_sha}"
67+
publish="true"
68+
elif [[ "${GITHUB_EVENT_NAME}" == "workflow_dispatch" ]]; then
69+
version="${ref_name_safe}-${short_sha}"
70+
publish="true"
5371
else
54-
version="${GITHUB_REF_NAME//\//-}-${short_sha}"
72+
version="${ref_name_safe}-${short_sha}"
5573
fi
5674
5775
owner="$(echo "${GITHUB_REPOSITORY_OWNER}" | tr '[:upper:]' '[:lower:]')"
5876
repo="$(echo "${GITHUB_REPOSITORY#*/}" | tr '[:upper:]' '[:lower:]')"
5977
image_repo="ghcr.io/${owner}/${repo}"
6078
61-
echo "version=${version}" >> "${GITHUB_OUTPUT}"
6279
echo "image_repo=${image_repo}" >> "${GITHUB_OUTPUT}"
80+
echo "version=${version}" >> "${GITHUB_OUTPUT}"
81+
echo "ref_name_safe=${ref_name_safe}" >> "${GITHUB_OUTPUT}"
82+
echo "short_sha=${short_sha}" >> "${GITHUB_OUTPUT}"
6383
echo "publish=${publish}" >> "${GITHUB_OUTPUT}"
84+
echo "release=${release}" >> "${GITHUB_OUTPUT}"
6485
echo "Using image repository: ${image_repo}"
6586
echo "Using version: ${version}"
6687
echo "Publish Docker images: ${publish}"
88+
echo "Release Docker tags: ${release}"
6789
6890
build:
6991
name: Build server${{ matrix.config.display_suffix }}
@@ -82,17 +104,23 @@ jobs:
82104
platforms: linux/amd64,linux/arm64
83105
free_disk_space: false
84106
- name: cuda12
85-
display_suffix: " CUDA 12"
107+
display_suffix: " CUDA 12.4"
86108
dockerfile: .devops/cuda.Dockerfile
87-
cuda_version: "12.8.1"
109+
cuda_version: "12.4.1"
110+
ubuntu_version: "22.04"
111+
cuda_arch: "default"
112+
cuda_build_target: "llama-server"
88113
tag_suffixes: "-cuda -cuda12"
89114
cache_name: cuda12
90115
platforms: linux/amd64
91116
free_disk_space: true
92117
- name: cuda13
93-
display_suffix: " CUDA 13"
118+
display_suffix: " CUDA 13.1"
94119
dockerfile: .devops/cuda.Dockerfile
95120
cuda_version: "13.1.1"
121+
ubuntu_version: "24.04"
122+
cuda_arch: "default"
123+
cuda_build_target: "llama-server"
96124
tag_suffixes: "-cuda13"
97125
cache_name: cuda13
98126
platforms: linux/amd64
@@ -153,6 +181,9 @@ jobs:
153181
env:
154182
IMAGE_REPO: ${{ needs.docker-meta.outputs.image_repo }}
155183
VERSION: ${{ needs.docker-meta.outputs.version }}
184+
REF_NAME_SAFE: ${{ needs.docker-meta.outputs.ref_name_safe }}
185+
SHORT_SHA: ${{ needs.docker-meta.outputs.short_sha }}
186+
RELEASE_TAGS: ${{ needs.docker-meta.outputs.release }}
156187
TAG_SUFFIXES: ${{ matrix.config.tag_suffixes }}
157188
CACHE_NAME: ${{ matrix.config.cache_name }}
158189
run: |
@@ -163,8 +194,14 @@ jobs:
163194
if [[ "${suffix}" == "none" ]]; then
164195
suffix=""
165196
fi
166-
tags+=("${IMAGE_REPO}:server${suffix}")
167-
tags+=("${IMAGE_REPO}:server${suffix}-${VERSION}")
197+
198+
if [[ "${RELEASE_TAGS}" == "true" ]]; then
199+
tags+=("${IMAGE_REPO}:server${suffix}")
200+
tags+=("${IMAGE_REPO}:server${suffix}-${VERSION}")
201+
else
202+
tags+=("${IMAGE_REPO}:server${suffix}-${REF_NAME_SAFE}-dev")
203+
tags+=("${IMAGE_REPO}:server${suffix}-${REF_NAME_SAFE}-${SHORT_SHA}")
204+
fi
168205
done
169206
170207
{
@@ -193,7 +230,10 @@ jobs:
193230
APP_REVISION=${{ github.sha }}
194231
IMAGE_URL=${{ github.server_url }}/${{ github.repository }}
195232
IMAGE_SOURCE=${{ github.server_url }}/${{ github.repository }}
233+
${{ matrix.config.ubuntu_version && format('UBUNTU_VERSION={0}', matrix.config.ubuntu_version) || '' }}
196234
${{ matrix.config.cuda_version && format('CUDA_VERSION={0}', matrix.config.cuda_version) || '' }}
235+
${{ matrix.config.cuda_arch && format('CUDA_DOCKER_ARCH={0}', matrix.config.cuda_arch) || '' }}
236+
${{ matrix.config.cuda_build_target && format('CUDA_BUILD_TARGET={0}', matrix.config.cuda_build_target) || '' }}
197237
annotations: |
198238
manifest:org.opencontainers.image.created=${{ steps.build_date.outputs.date }}
199239
manifest:org.opencontainers.image.version=${{ needs.docker-meta.outputs.version }}

docs/docker.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Docker
22

3-
BeeLlama Docker images are published by the daily/manual Docker workflow to
3+
BeeLlama Docker images are published by the push/manual Docker workflow to
44
`ghcr.io/anbeeld/beellama.cpp`. CUDA images are built from the stock
55
`.devops/cuda.Dockerfile`; pass `CUDA_DOCKER_ARCH` when building locally for a
66
specific GPU generation, for example `120` for Blackwell or `86` for RTX 3090.
@@ -22,8 +22,8 @@ Additionally, there the following images, similar to the above:
2222
- `ghcr.io/anbeeld/beellama.cpp:full-cuda13`: Same as `full` but compiled with CUDA 13 support. (platforms: `linux/amd64`, `linux/arm64`)
2323
- `ghcr.io/anbeeld/beellama.cpp:light-cuda`: Same as `light` but compiled with CUDA 12 support. (platforms: `linux/amd64`, `linux/arm64`)
2424
- `ghcr.io/anbeeld/beellama.cpp:light-cuda13`: Same as `light` but compiled with CUDA 13 support. (platforms: `linux/amd64`, `linux/arm64`)
25-
- `ghcr.io/anbeeld/beellama.cpp:server-cuda`: Same as `server` but compiled with CUDA 12 support. (platforms: `linux/amd64`, `linux/arm64`)
26-
- `ghcr.io/anbeeld/beellama.cpp:server-cuda13`: Same as `server` but compiled with CUDA 13 support. (platforms: `linux/amd64`, `linux/arm64`)
25+
- `ghcr.io/anbeeld/beellama.cpp:server-cuda`: Same as `server` but compiled with CUDA 12.4 support. (platforms: `linux/amd64`)
26+
- `ghcr.io/anbeeld/beellama.cpp:server-cuda13`: Same as `server` but compiled with CUDA 13.1 support. (platforms: `linux/amd64`)
2727
- `ghcr.io/anbeeld/beellama.cpp:full-rocm`: Same as `full` but compiled with ROCm support. (platforms: `linux/amd64`)
2828
- `ghcr.io/anbeeld/beellama.cpp:light-rocm`: Same as `light` but compiled with ROCm support. (platforms: `linux/amd64`)
2929
- `ghcr.io/anbeeld/beellama.cpp:server-rocm`: Same as `server` but compiled with ROCm support. (platforms: `linux/amd64`)
@@ -93,7 +93,8 @@ You may want to pass in some different `ARGS`, depending on the CUDA environment
9393

9494
The defaults are:
9595

96-
- `CUDA_VERSION` set to `12.8.1`
96+
- `CUDA_VERSION` set to `12.4.1`
97+
- `UBUNTU_VERSION` set to `22.04`
9798
- `CUDA_DOCKER_ARCH` set to the cmake build default, which includes all the supported architectures
9899

99100
The resulting images, are essentially the same as the non-CUDA images:

0 commit comments

Comments
 (0)