| 1 | # Diffinery runner image (Cloudflare Containers, linux/amd64). |
| 2 | # Build context: containers/runner. Run `pnpm build` first so dist/agent.mjs exists. |
| 3 | # |
| 4 | # docker build --platform linux/amd64 -t diffinery-runner containers/runner |
| 5 | ARG BASE_IMAGE=ubuntu:24.04 |
| 6 | FROM ${BASE_IMAGE} |
| 7 | |
| 8 | ARG NODE_VERSION=22.22.0 |
| 9 | |
| 10 | ENV DEBIAN_FRONTEND=noninteractive \ |
| 11 | LANG=C.UTF-8 \ |
| 12 | LC_ALL=C.UTF-8 \ |
| 13 | DIFFINERY_WORK_ROOT=/workspace \ |
| 14 | RUNNER_TOOL_CACHE=/opt/hostedtoolcache \ |
| 15 | AGENT_TOOLSDIRECTORY=/opt/hostedtoolcache \ |
| 16 | COREPACK_ENABLE_DOWNLOAD_PROMPT=0 \ |
| 17 | # Ubuntu 24.04 marks the system Python as externally managed (PEP 668); |
| 18 | # CI scripts commonly `pip install` directly, so allow it like hosted runners do. |
| 19 | PIP_BREAK_SYSTEM_PACKAGES=1 |
| 20 | |
| 21 | RUN apt-get update \ |
| 22 | && apt-get install -y --no-install-recommends \ |
| 23 | ca-certificates curl git jq zip unzip xz-utils tar gzip \ |
| 24 | build-essential pkg-config openssh-client gnupg \ |
| 25 | python3 python3-pip python3-venv python-is-python3 \ |
| 26 | && git config --system --add safe.directory '*' \ |
| 27 | && apt-get clean \ |
| 28 | && rm -rf /var/lib/apt/lists/* /var/cache/apt/archives/* |
| 29 | |
| 30 | # Node.js LTS from the official tarball (checksum-verified), with corepack shims for pnpm/yarn. |
| 31 | RUN set -eux; \ |
| 32 | cd /tmp; \ |
| 33 | file="node-v${NODE_VERSION}-linux-x64.tar.xz"; \ |
| 34 | curl -fsSLO "https://nodejs.org/dist/v${NODE_VERSION}/${file}"; \ |
| 35 | curl -fsSL "https://nodejs.org/dist/v${NODE_VERSION}/SHASUMS256.txt" | grep " ${file}\$" | sha256sum -c -; \ |
| 36 | tar -xJf "${file}" -C /usr/local --strip-components=1 --no-same-owner \ |
| 37 | --exclude='*/CHANGELOG.md' --exclude='*/README.md' --exclude='*/LICENSE' --exclude='*/include/*' --exclude='*/share/doc/*'; \ |
| 38 | rm -f "${file}"; \ |
| 39 | corepack enable; \ |
| 40 | corepack prepare pnpm@10.28.0 --activate; \ |
| 41 | corepack prepare yarn@1.22.22 --activate; \ |
| 42 | node --version; npm --version; pnpm --version; yarn --version; \ |
| 43 | npm cache clean --force; \ |
| 44 | rm -rf /root/.npm /tmp/* |
| 45 | |
| 46 | RUN mkdir -p /workspace /opt/hostedtoolcache /opt/diffinery |
| 47 | COPY dist/agent.mjs /opt/diffinery/agent.mjs |
| 48 | |
| 49 | WORKDIR /workspace |
| 50 | EXPOSE 8080 |
| 51 | ENTRYPOINT ["node", "/opt/diffinery/agent.mjs"] |