Files
runner-images/dockerfiles/ubuntu.dockerfile
T
fristy 6cacaf221c
build / build (26.04) (pull_request) Successful in 3m36s
build / build (24.04) (pull_request) Successful in 3m39s
build / build (26.10) (pull_request) Successful in 3m44s
fix(ci): survive expired github download urls
GitHub answers a release asset download with HTTP 618 (jwt:expired) once the signed URL has expired, and the build layer dies on it. Two runs in a row lost build (24.04) on gh_2.106.0_linux_amd64.tar.gz while the same file downloaded fine in a sibling job of the same run.

Wrap curl in /usr/local/bin with retries and a no-cache request header, which covers the Dockerfile downloads and installer scripts such as cargo-zigbuild-installer.sh. Pull request builds also read the buildcache-<base> registry cache that release.yaml writes on every main push, so a cache hit skips the downloads.

Signed-off-by: fristyxd <gpg@fristy.dev>
2026-12-01 13:36:29 +03:00

258 lines
11 KiB
Docker

# syntax=docker/dockerfile:1
ARG BASE_IMAGE_TAG=26.10
FROM buildpack-deps:${BASE_IMAGE_TAG}
ARG TARGETARCH
ARG BASE_IMAGE_TAG
# renovate: datasource=node-version depName=node
ARG NODE_VERSION=26.13.1
# renovate: datasource=npm depName=npm
ARG NPM_VERSION=12.2.3
# renovate: datasource=npm depName=pnpm
ARG PNPM_VERSION=12.24.0
# renovate: datasource=npm depName=corepack
ARG COREPACK_VERSION=0.36.0
# renovate: datasource=github-releases depName=mikefarah/yq
ARG YQ_VERSION=v4.54.3
# renovate: datasource=gitea-releases depName=gitea/tea
ARG TEA_VERSION=0.16.0
# renovate: datasource=golang-version depName=golang
ARG GO_VERSION=1.27.4
# renovate: datasource=github-releases depName=cli/cli
ARG GH_VERSION=2.106.0
# renovate: datasource=github-releases depName=aquasecurity/trivy
ARG TRIVY_VERSION=0.76.2
# renovate: datasource=github-releases depName=goreleaser/nfpm
ARG NFPM_VERSION=2.49.0
# renovate: datasource=github-releases depName=rust-cross/cargo-zigbuild
ARG CARGO_ZIGBUILD_VERSION=0.24.1
# Renovate has no datasource for zig; bump from https://ziglang.org/download/index.json by hand.
ARG ZIG_VERSION=0.17.0
ENV DEBIAN_FRONTEND=noninteractive \
LANG=C.UTF-8 \
LC_ALL=C.UTF-8 \
ImageOS=ubuntu${BASE_IMAGE_TAG%%.*} \
IMAGE_OS=ubuntu${BASE_IMAGE_TAG%%.*} \
AGENT_TOOLSDIRECTORY=/opt/hostedtoolcache \
RUNNER_TOOL_CACHE=/opt/hostedtoolcache \
USER=root \
RUNNER_USER=root \
PIPX_HOME=/opt/pipx \
PIPX_BIN_DIR=/opt/pipx_bin \
RUSTUP_HOME=/usr/local/rustup \
CARGO_HOME=/usr/local/cargo \
PATH=/usr/local/cargo/bin:/opt/pipx_bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
SHELL ["/bin/bash", "-e", "-o", "pipefail", "-c"]
RUN printf '%s\n' \
'#!/bin/sh' \
'exec /usr/bin/curl --retry 5 --retry-all-errors --retry-delay 2 -H "Cache-Control: no-cache" "$@"' \
> /usr/local/bin/curl \
&& chmod 0755 /usr/local/bin/curl
RUN case "${TARGETARCH}" in \
amd64) arch=x86_64; goarch=amd64; node_arch=x64; gh_arch=amd64; trivy_arch=64bit; zig_arch=x86_64 ;; \
arm64) arch=aarch64; goarch=arm64; node_arch=arm64; gh_arch=arm64; trivy_arch=ARM64; zig_arch=aarch64 ;; \
*) echo "unsupported architecture: ${TARGETARCH}" >&2; exit 1 ;; \
esac \
&& echo "${arch}" > /tmp/arch \
&& echo "${goarch}" > /tmp/goarch \
&& echo "${node_arch}" > /tmp/node_arch \
&& echo "${gh_arch}" > /tmp/gh_arch \
&& echo "${trivy_arch}" > /tmp/trivy_arch \
&& echo "${zig_arch}" > /tmp/zig_arch
# buildpack-deps already brings compilers, curl and git; add only the gaps.
RUN echo 'Acquire::Retries "3";' > /etc/apt/apt.conf.d/80-retries \
&& apt-get update \
&& apt-get install -y --no-install-recommends \
ca-certificates \
file \
git-lfs \
gnupg \
iproute2 \
jq \
less \
lsb-release \
musl-tools \
netcat-openbsd \
patchelf \
pigz \
pipx \
pkg-config \
python3-dev \
python3-pip \
python3-venv \
rsync \
shellcheck \
software-properties-common \
sqlite3 \
sudo \
tree \
unzip \
wget \
xz-utils \
zip \
zstd \
&& apt-get upgrade -y \
&& . /etc/os-release \
&& install -m 0755 -d /etc/apt/keyrings \
&& curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc \
&& echo "deb [arch=${TARGETARCH} signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/ubuntu ${VERSION_CODENAME} stable" > /etc/apt/sources.list.d/docker.list \
&& apt-get update \
&& apt-get install -y --no-install-recommends \
docker-buildx-plugin \
docker-ce-cli \
docker-compose-plugin \
&& rm -rf /var/lib/apt/lists/* /etc/apt/sources.list.d/docker.list /etc/apt/keyrings/docker.asc \
&& git config --system --add safe.directory '*' \
&& git lfs install --system \
&& pipx install yamllint \
&& chmod -R 777 /opt/pipx /opt/pipx_bin \
&& rm -rf ~/.cache
# npm upgrades break the hardlink, so the tool-cache copy is replaced below.
RUN node_arch="$(cat /tmp/node_arch)" \
&& cd /tmp \
&& base_url="https://nodejs.org/dist/v${NODE_VERSION}" \
&& curl -fsSLO "${base_url}/SHASUMS256.txt" \
&& tarball="node-v${NODE_VERSION}-linux-${node_arch}.tar.xz" \
&& curl -fsSLO "${base_url}/${tarball}" \
&& grep " ${tarball}\$" SHASUMS256.txt | sha256sum -c - \
&& node_dir="/opt/hostedtoolcache/node/${NODE_VERSION}/${node_arch}" \
&& mkdir -p "${node_dir}" \
&& tar -xJf "${tarball}" -C "${node_dir}" --strip-components=1 --no-same-owner \
&& touch "${node_dir}.complete" \
&& chmod 777 /opt/hostedtoolcache /opt/hostedtoolcache/node \
&& cp -al "${node_dir}/bin" "${node_dir}/include" "${node_dir}/lib" "${node_dir}/share" /usr/local/ \
&& rm -f "${tarball}" SHASUMS256.txt \
&& node --version \
&& npm install -g "npm@${NPM_VERSION}" "pnpm@${PNPM_VERSION}" "corepack@${COREPACK_VERSION}" \
&& rm -rf "${node_dir}/lib/node_modules/npm" \
&& cp -a /usr/local/lib/node_modules/npm "${node_dir}/lib/node_modules/npm" \
&& rm -rf ~/.npm \
&& npm --version \
&& pnpm --version \
&& corepack --version
RUN arch="$(cat /tmp/arch)" \
&& cd /tmp \
&& base_url="https://github.com/mikefarah/yq/releases/download/${YQ_VERSION}" \
&& curl -fsSLO "${base_url}/yq_linux_${TARGETARCH}" \
&& curl -fsSL "${base_url}/checksums-bsd" | grep "^SHA256 (yq_linux_${TARGETARCH})" | sha256sum -c - \
&& install -m 0755 "yq_linux_${TARGETARCH}" /usr/bin/yq \
&& rm -f "yq_linux_${TARGETARCH}" \
&& yq --version
RUN cd /tmp \
&& base_url="https://dl.gitea.com/tea/${TEA_VERSION}" \
&& binary="tea-${TEA_VERSION}-linux-${TARGETARCH}" \
&& curl -fsSLO "${base_url}/${binary}" \
&& curl -fsSL "${base_url}/${binary}.sha256" | sha256sum -c - \
&& install -m 0755 "${binary}" /usr/local/bin/tea \
&& rm -f "${binary}" \
&& tea --version
RUN goarch="$(cat /tmp/goarch)" \
&& cd /tmp \
&& tarball="go${GO_VERSION}.linux-${goarch}.tar.gz" \
&& curl -fsSLO "https://go.dev/dl/${tarball}" \
&& curl -fsSL "https://go.dev/dl/?mode=json&include=all" -o go.json \
&& sha="$(jq -r --arg v "go${GO_VERSION}" --arg f "${tarball}" '.[] | select(.version == $v) | .files[] | select(.filename == $f) | .sha256' go.json)" \
&& echo "${sha} ${tarball}" | sha256sum -c - \
&& tar -C /usr/local -xzf "${tarball}" \
&& rm -f "${tarball}" go.json \
&& ln -sf /usr/local/go/bin/go /usr/local/bin/go \
&& ln -sf /usr/local/go/bin/gofmt /usr/local/bin/gofmt \
&& go version
RUN gh_arch="$(cat /tmp/gh_arch)" \
&& cd /tmp \
&& tarball="gh_${GH_VERSION}_linux_${gh_arch}.tar.gz" \
&& curl -fsSLO "https://github.com/cli/cli/releases/download/v${GH_VERSION}/${tarball}" \
&& curl -fsSL "https://github.com/cli/cli/releases/download/v${GH_VERSION}/gh_${GH_VERSION}_checksums.txt" -o checksums.txt \
&& grep " ${tarball}\$" checksums.txt | sha256sum -c - \
&& tar -xzf "${tarball}" \
&& install -m 0755 "gh_${GH_VERSION}_linux_${gh_arch}/bin/gh" /usr/local/bin/gh \
&& rm -rf "${tarball}" checksums.txt "gh_${GH_VERSION}_linux_${gh_arch}" \
&& gh --version
RUN trivy_arch="$(cat /tmp/trivy_arch)" \
&& cd /tmp \
&& tarball="trivy_${TRIVY_VERSION}_Linux-${trivy_arch}.tar.gz" \
&& curl -fsSLO "https://github.com/aquasecurity/trivy/releases/download/v${TRIVY_VERSION}/${tarball}" \
&& curl -fsSL "https://github.com/aquasecurity/trivy/releases/download/v${TRIVY_VERSION}/trivy_${TRIVY_VERSION}_checksums.txt" -o checksums.txt \
&& grep " ${tarball}\$" checksums.txt | sha256sum -c - \
&& tar -xzf "${tarball}" -C /tmp trivy \
&& install -m 0755 /tmp/trivy /usr/local/bin/trivy \
&& rm -f "${tarball}" checksums.txt /tmp/trivy \
&& trivy --version
RUN arch="$(cat /tmp/arch)" \
&& pkg_arch="$([[ "${TARGETARCH}" == "amd64" ]] && echo x86_64 || echo arm64)" \
&& cd /tmp \
&& tarball="nfpm_${NFPM_VERSION}_Linux_${pkg_arch}.tar.gz" \
&& curl -fsSLO "https://github.com/goreleaser/nfpm/releases/download/v${NFPM_VERSION}/${tarball}" \
&& curl -fsSL "https://github.com/goreleaser/nfpm/releases/download/v${NFPM_VERSION}/checksums.txt" -o checksums.txt \
&& grep " ${tarball}\$" checksums.txt | sha256sum -c - \
&& tar -xzf "${tarball}" nfpm \
&& install -m 0755 nfpm /usr/local/bin/nfpm \
&& rm -f "${tarball}" checksums.txt nfpm \
&& nfpm --version
RUN zig_arch="$(cat /tmp/zig_arch)" \
&& cd /tmp \
&& info="$(curl -fsSL https://ziglang.org/download/index.json)" \
&& tarball_url="$(echo "${info}" | jq -r --arg v "${ZIG_VERSION}" --arg k "${zig_arch}-linux" '.[$v][$k].tarball')" \
&& shasum="$(echo "${info}" | jq -r --arg v "${ZIG_VERSION}" --arg k "${zig_arch}-linux" '.[$v][$k].shasum')" \
&& [ -n "${tarball_url}" ] && [ "${tarball_url}" != "null" ] || { echo "zig ${ZIG_VERSION} not found for ${zig_arch}-linux" >&2; exit 1; } \
&& tarball="$(basename "${tarball_url}")" \
&& curl -fsSLO "${tarball_url}" \
&& echo "${shasum} ${tarball}" | sha256sum -c - \
&& mkdir -p /opt/zig \
&& tar -xJf "${tarball}" -C /opt/zig --strip-components=1 \
&& ln -sf /opt/zig/zig /usr/local/bin/zig \
&& rm -f "${tarball}" \
&& zig version
RUN arch="$(cat /tmp/arch)" \
&& curl -fsSL "https://static.rust-lang.org/rustup/dist/${arch}-unknown-linux-gnu/rustup-init" -o /tmp/rustup-init \
&& chmod +x /tmp/rustup-init \
&& /tmp/rustup-init -y --profile minimal --default-toolchain stable --no-modify-path \
&& rm -f /tmp/rustup-init \
&& rustup target add aarch64-unknown-linux-musl \
&& curl --proto '=https' --tlsv1.2 -LsSf "https://github.com/rust-cross/cargo-zigbuild/releases/download/v${CARGO_ZIGBUILD_VERSION}/cargo-zigbuild-installer.sh" | sh \
&& rustc --version \
&& cargo --version \
&& cargo zigbuild --help > /dev/null
RUN mkdir -m 0777 -p /github /opt/hostedtoolcache \
&& mkdir -m 0700 -p ~/.ssh \
&& ssh-keyscan -t rsa,ecdsa,ed25519 github.com gitea.com >> /etc/ssh/ssh_known_hosts \
&& rm -f /tmp/arch /tmp/goarch /tmp/node_arch /tmp/gh_arch /tmp/trivy_arch /tmp/zig_arch
ARG IMAGE_CREATED
ARG IMAGE_VERSION
ARG IMAGE_REVISION
ENV ImageVersion=${IMAGE_VERSION}
LABEL org.opencontainers.image.created="${IMAGE_CREATED}" \
org.opencontainers.image.authors="fristy" \
org.opencontainers.image.url="https://git.fristy.net/actions/runner-images" \
org.opencontainers.image.documentation="https://git.fristy.net/actions/runner-images/src/branch/main/README.md" \
org.opencontainers.image.source="https://git.fristy.net/actions/runner-images" \
org.opencontainers.image.version="${IMAGE_VERSION}" \
org.opencontainers.image.revision="${IMAGE_REVISION}" \
org.opencontainers.image.vendor="fristy" \
org.opencontainers.image.licenses="MIT" \
org.opencontainers.image.title="Gitea Actions runner images" \
org.opencontainers.image.description="Runner images for our fristea actions runners."
WORKDIR /github