From 1d636d63fae988bd54f4725559300776062fd2f6 Mon Sep 17 00:00:00 2001 From: spinline Date: Fri, 6 Feb 2026 22:16:04 +0300 Subject: [PATCH] feat: add self-contained gitea runner dockerfile with all build tools included --- docker/runner/Dockerfile | 80 +++++++++++++++++++++++++++++++++++++ docker/runner/entrypoint.sh | 20 ++++++++++ 2 files changed, 100 insertions(+) create mode 100644 docker/runner/Dockerfile create mode 100644 docker/runner/entrypoint.sh diff --git a/docker/runner/Dockerfile b/docker/runner/Dockerfile new file mode 100644 index 0000000..cf77e93 --- /dev/null +++ b/docker/runner/Dockerfile @@ -0,0 +1,80 @@ +# Use a base image that supports multi-arch (x64 and arm64) +# We use debian:bookworm-slim as base to install everything manually +# and then install the act_runner binary. +FROM debian:bookworm-slim + +ENV DEBIAN_FRONTEND=noninteractive +ENV PATH="/root/.cargo/bin:/root/.node/bin:/root/zig:${PATH}" + +# 1. Install Basic Dependencies +RUN apt-get update && apt-get install -y \ + curl \ + git \ + build-essential \ + ca-certificates \ + wget \ + xz-utils \ + libssl-dev \ + pkg-config \ + # Needed for some crate compilations + protobuf-compiler \ + && rm -rf /var/lib/apt/lists/* + +# 2. Install Node.js v20 (Manual install to support multi-arch cleanly) +RUN ARCH=$(dpkg --print-architecture) && \ + if [ "$ARCH" = "amd64" ]; then NODE_ARCH="x64"; \ + elif [ "$ARCH" = "arm64" ]; then NODE_ARCH="arm64"; fi && \ + NODE_VER="v20.11.1" && \ + curl -fsSL "https://nodejs.org/dist/$NODE_VER/node-$NODE_VER-linux-$NODE_ARCH.tar.xz" -o node.tar.xz && \ + mkdir -p /root/.node && \ + tar -xJf node.tar.xz -C /root/.node --strip-components=1 && \ + rm node.tar.xz + +# 3. Install Rust (Nightly) + Targets +RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain nightly --profile minimal && \ + . "$HOME/.cargo/env" && \ + rustup target add wasm32-unknown-unknown && \ + rustup target add mips-unknown-linux-musl && \ + rustup component add rust-src + +# 4. Install Zig (for Cross Compilation) +RUN ARCH=$(dpkg --print-architecture) && \ + if [ "$ARCH" = "amd64" ]; then ZIG_ARCH="x86_64"; \ + elif [ "$ARCH" = "arm64" ]; then ZIG_ARCH="aarch64"; fi && \ + ZIG_VER="0.13.0" && \ + curl -fsSL "https://ziglang.org/download/$ZIG_VER/zig-linux-$ZIG_ARCH-$ZIG_VER.tar.xz" -o zig.tar.xz && \ + tar -xf zig.tar.xz && \ + mv "zig-linux-$ZIG_ARCH-$ZIG_VER" /root/zig && \ + rm zig.tar.xz + +# 5. Install Tools (Trunk, cargo-zigbuild, wasm-bindgen protocol aligned) +# We install trunk binary to save time, others via cargo +RUN . "$HOME/.cargo/env" && \ + # Install cargo-zigbuild + cargo install cargo-zigbuild && \ + # Install trunk (Binary) + ARCH=$(dpkg --print-architecture) && \ + if [ "$ARCH" = "amd64" ]; then TRUNK_ARCH="x86_64-unknown-linux-gnu"; \ + elif [ "$ARCH" = "arm64" ]; then TRUNK_ARCH="aarch64-unknown-linux-gnu"; fi && \ + wget -qO- "https://github.com/trunk-rs/trunk/releases/download/v0.21.5/trunk-$TRUNK_ARCH.tar.gz" | tar -xzf - -C /root/.cargo/bin/ && \ + chmod +x /root/.cargo/bin/trunk && \ + # Install wasm-bindgen-cli (Compiling from source to avoid glibc issues, doing it ONCE here) + cargo install wasm-bindgen-cli --version 0.2.108 + +# 6. Install Gitea Act Runner Binary +# We fetch the binary directly to run as the entrypoint +RUN ARCH=$(dpkg --print-architecture) && \ + VERSION="0.2.11" && \ + curl -fsSL -o /usr/local/bin/act_runner "https://gitea.com/gitea/act_runner/releases/download/v$VERSION/act_runner-$VERSION-linux-$ARCH" && \ + chmod +x /usr/local/bin/act_runner + +# Create a volume for registration data +VOLUME /data +WORKDIR /data + +# Define entrypoint to run the registration or daemon +# We will use a script to handle auto-registration if env vars are present +COPY entrypoint.sh /entrypoint.sh +RUN chmod +x /entrypoint.sh + +ENTRYPOINT ["/entrypoint.sh"] diff --git a/docker/runner/entrypoint.sh b/docker/runner/entrypoint.sh new file mode 100644 index 0000000..07f98bb --- /dev/null +++ b/docker/runner/entrypoint.sh @@ -0,0 +1,20 @@ +#!/bin/bash +set -e + +# If GITEA_INSTANCE_URL and GITEA_RUNNER_TOKEN are provided, try to register +if [ -n "$GITEA_INSTANCE_URL" ] && [ -n "$GITEA_RUNNER_TOKEN" ]; then + if [ ! -f ".runner" ]; then + echo "Registering runner..." + act_runner register \ + --instance "$GITEA_INSTANCE_URL" \ + --token "$GITEA_RUNNER_TOKEN" \ + --name "custom-mips-runner-$(hostname)" \ + --no-interactive + else + echo "Runner already registered." + fi +fi + +# Run the daemon +echo "Starting act_runner daemon..." +exec act_runner daemon