diff --git a/.gitea/workflows/build-ci-image.yml b/.gitea/workflows/build-ci-image.yml index ea80e25..3b86ba6 100644 --- a/.gitea/workflows/build-ci-image.yml +++ b/.gitea/workflows/build-ci-image.yml @@ -37,15 +37,30 @@ jobs: -u "$username" \ --password-stdin - - name: Build CI image + - name: Build and push CI image + env: + DOCKER_BUILDKIT: 1 run: | - docker build \ - --build-arg BASE_IMAGE=catthehacker/ubuntu:act-latest \ - --build-arg LLVM_VERSION=22 \ - --build-arg MESON_VERSION=latest \ - -t "$REGISTRY_IMAGE:latest" \ - -f Dockerfile . - - - name: Push CI image - run: | - docker push "$REGISTRY_IMAGE:latest" + if docker buildx version >/dev/null 2>&1; then + docker buildx create --use --name evol-testbed-builder || docker buildx use evol-testbed-builder + docker buildx build \ + --build-arg BASE_IMAGE=catthehacker/ubuntu:act-latest \ + --build-arg LLVM_VERSION=22 \ + --build-arg MESON_VERSION=latest \ + --cache-from type=registry,ref="$REGISTRY_IMAGE:buildcache" \ + --cache-to type=registry,ref="$REGISTRY_IMAGE:buildcache",mode=max \ + --tag "$REGISTRY_IMAGE:latest" \ + --file Dockerfile \ + --push \ + . + else + echo "docker buildx is unavailable; falling back to uncached docker build" + docker build \ + --build-arg BASE_IMAGE=catthehacker/ubuntu:act-latest \ + --build-arg LLVM_VERSION=22 \ + --build-arg MESON_VERSION=latest \ + --tag "$REGISTRY_IMAGE:latest" \ + --file Dockerfile \ + . + docker push "$REGISTRY_IMAGE:latest" + fi diff --git a/Dockerfile b/Dockerfile index c5ff1de..8515e9a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,3 +1,4 @@ +# syntax=docker/dockerfile:1.7 # Gitea Actions CI image for C/C++ + Vulkan projects. # This extends the Ubuntu image commonly used by Gitea/act_runner so JS actions # such as actions/checkout keep working. @@ -24,7 +25,8 @@ ENV STRIP=llvm-strip SHELL ["/bin/bash", "-o", "pipefail", "-c"] # Base compiler/build/Python/Vulkan packages from Ubuntu. -RUN set -eux; \ +RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \ + set -eux; \ apt-get update; \ apt-get install -y --no-install-recommends \ ca-certificates \ @@ -55,7 +57,8 @@ RUN set -eux; \ rm -rf /var/lib/apt/lists/* # LLVM/Clang from apt.llvm.org. -RUN set -eux; \ +RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \ + set -eux; \ codename="$(. /etc/os-release && echo "${VERSION_CODENAME}")"; \ curl -fsSL https://apt.llvm.org/llvm-snapshot.gpg.key \ | gpg --dearmor -o /usr/share/keyrings/llvm-snapshot.gpg; \ @@ -76,7 +79,8 @@ RUN set -eux; \ # Optional LunarG Vulkan SDK repo. Disabled by default because Ubuntu distro # Vulkan packages are more stable for CI and usually enough for building/testing. -RUN set -eux; \ +RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \ + set -eux; \ if [ "${USE_LUNARG_VULKAN}" = "true" ]; then \ codename="$(. /etc/os-release && echo "${VERSION_CODENAME}")"; \ curl -fsSL https://packages.lunarg.com/lunarg-signing-key-pub.asc \ @@ -101,7 +105,8 @@ RUN set -eux; \ update-alternatives --install /usr/bin/llvm-strip llvm-strip "/usr/bin/llvm-strip-${LLVM_VERSION}" 100 # Meson in an isolated venv avoids Debian/Ubuntu PEP 668 externally-managed pip errors. -RUN set -eux; \ +RUN --mount=type=cache,target=/root/.cache/pip \ + set -eux; \ python3 -m venv /opt/meson-venv; \ /opt/meson-venv/bin/python -m pip install --upgrade pip setuptools wheel; \ if [ "${MESON_VERSION}" = "latest" ]; then \ @@ -117,7 +122,6 @@ RUN set -eux; \ clang --version; \ clang++ --version; \ meson --version; \ - ninja --version; \ - vulkaninfo --summary || true + ninja --version CMD ["bash"]