agent-sandbox/Dockerfile.original
2026-05-02 00:37:38 +08:00

208 lines
9.6 KiB
Text

# build to "openclaw-sandbox:13-slim"
# Import Homebrew
FROM scratch AS brew
COPY --from=ghcr.io/ublue-os/brew:latest /system_files /
# Prepare Helium browser
FROM ghcr.io/xlionjuan/fedora-createrepo-image:latest AS browser
RUN xlion-repo-utils-gh --workfolder /tmp/helium --repo imputnet/helium-linux
RUN cd /tmp/helium && cat dl_urls.txt | grep -E '\.deb$' | grep amd64 | wget2 --input-file=-
RUN xlion-repo-utils-gh --verify --workfolder /tmp/helium
RUN cd /tmp/helium && mv helium-bin* helium-bin.deb
RUN cp /tmp/helium/helium-bin.deb /opt/helium-bin.deb
# Prepare FFmepg static build from yt-dlp
FROM ghcr.io/xlionjuan/fedora-createrepo-image:latest AS ffmpeg-static
RUN xlion-repo-utils-gh --workfolder /tmp/ffmpeg-static --repo yt-dlp/FFmpeg-Builds
RUN cd /tmp/ffmpeg-static && cat dl_urls.txt | grep "linux64-gpl.tar.xz" | wget2 --input-file=-
RUN xlion-repo-utils-gh --verify --workfolder /tmp/ffmpeg-static
RUN cd /tmp/ffmpeg-static && tar -xJf *.tar.xz --strip-components=1 && cp -r /tmp/ffmpeg-static/bin/* /opt
# Import Micromamba
FROM registry.hub.docker.com/mambaorg/micromamba:latest AS micromamba
FROM debian:13-slim
ENV DEBIAN_FRONTEND=noninteractive
ENV TZ=Asia/Taipei
# Brew related
ARG BREW_INSTALL_DIR=/home/linuxbrew/.linuxbrew
ENV HOMEBREW_PREFIX=${BREW_INSTALL_DIR}
ENV HOMEBREW_CELLAR=${BREW_INSTALL_DIR}/Cellar
ENV HOMEBREW_REPOSITORY=${BREW_INSTALL_DIR}/Homebrew
# Micromamba related
ARG MAMBA_USER=sandbox
ARG MAMBA_USER_ID=1000
ARG MAMBA_USER_GID=1000
ENV MAMBA_USER=$MAMBA_USER
ENV MAMBA_ROOT_PREFIX="/opt/conda"
ENV MAMBA_EXE="/bin/micromamba"
# APT mirrors (override at build time if needed)
ARG DEBIAN_MIRROR=https://cloudflaremirrors.com/debian
ARG DEBIAN_SECURITY_MIRROR=https://deb.debian.org/debian-security
# Copy Micromamba
COPY --from=micromamba "$MAMBA_EXE" "$MAMBA_EXE"
COPY --from=micromamba /usr/local/bin/_activate_current_env.sh /usr/local/bin/_activate_current_env.sh
COPY --from=micromamba /usr/local/bin/_dockerfile_shell.sh /usr/local/bin/_dockerfile_shell.sh
COPY --from=micromamba /usr/local/bin/_entrypoint.sh /usr/local/bin/_entrypoint.sh
COPY --from=micromamba /usr/local/bin/_dockerfile_initialize_user_accounts.sh /usr/local/bin/_dockerfile_initialize_user_accounts.sh
COPY --from=micromamba /usr/local/bin/_dockerfile_setup_root_prefix.sh /usr/local/bin/_dockerfile_setup_root_prefix.sh
# Bootstrap CA trust on default Debian sources first (needed before HTTPS mirrors)
RUN --mount=type=tmpfs,dst=/var/lib/apt/lists \
--mount=type=tmpfs,dst=/var/cache/apt \
apt-get update && \
apt-get install -y --no-install-recommends ca-certificates
# Rewrite /etc/apt/sources.list.d/debian.sources using sed (Deb822 format)
RUN sed -i "s|^URIs: http://deb.debian.org/debian-security$|URIs: ${DEBIAN_SECURITY_MIRROR}|" /etc/apt/sources.list.d/debian.sources \
&& sed -i "s|^URIs: http://deb.debian.org/debian$|URIs: ${DEBIAN_MIRROR}|" /etc/apt/sources.list.d/debian.sources
# Install curl, gnupg
RUN --mount=type=tmpfs,dst=/var/lib/apt/lists \
--mount=type=tmpfs,dst=/var/cache/apt \
apt-get update && apt-get install -y curl gnupg --no-install-recommends
# Install apt-fast
RUN --mount=type=tmpfs,dst=/var/lib/apt/lists \
--mount=type=tmpfs,dst=/var/cache/apt \
mkdir -p /etc/apt/keyrings && \
echo "deb [signed-by=/etc/apt/keyrings/apt-fast.gpg] http://ppa.launchpad.net/apt-fast/stable/ubuntu noble main" | tee /etc/apt/sources.list.d/apt-fast.list && \
curl -fsSL "https://keyserver.ubuntu.com/pks/lookup?op=get&search=0xBC5934FD3DEBD4DAEA544F791E2824A7F22B44BD" | gpg --dearmor -o /etc/apt/keyrings/apt-fast.gpg && \
apt-get update && apt-get install -y apt-fast
# Setup Adoptium repository to install jdk 25 (temurin-25-jdk)
RUN echo "deb https://packages.adoptium.net/artifactory/deb $(awk -F= '/^VERSION_CODENAME/{print$2}' /etc/os-release) main" | tee /etc/apt/sources.list.d/adoptium.list &&\
curl -fsSL https://packages.adoptium.net/artifactory/api/gpg/key/public | gpg --dearmor | tee /etc/apt/trusted.gpg.d/adoptium.gpg > /dev/null
# Install essential packages
RUN --mount=type=tmpfs,dst=/var/lib/apt/lists \
--mount=type=tmpfs,dst=/var/cache/apt \
--mount=type=bind,from=browser,source=/,target=/browser \
--mount=type=bind,from=ffmpeg-static,source=/,target=/ffmpeg-static \
curl -fsSL https://deb.nodesource.com/setup_22.x | bash && \
apt-fast install -y --no-install-recommends \
bash \
curl \
wget \
git \
jq \
python3 \
python3-pip \
ripgrep \
tzdata \
unzip \
dnsutils \
build-essential \
nodejs \
zstd \
poppler-utils \
temurin-25-jdk \
fonts-liberation \
fonts-noto-color-emoji \
fonts-noto-cjk-extra \
libxcb-shm0 libx11-xcb1 libx11-6 libxcb1 libxext6 libxrandr2 libxcomposite1 libxcursor1 libxdamage1 libxfixes3 libxi6 libgtk-3-0 libpangocairo-1.0-0 libpango-1.0-0 libatk1.0-0 libcairo-gobject2 libcairo2 libgdk-pixbuf-2.0-0 libxrender1 libasound2 libfreetype6 libfontconfig1 libdbus-1-3 libnss3 libnspr4 libatk-bridge2.0-0 libdrm2 libxkbcommon0 libatspi2.0-0 libcups2 libxshmfence1 libgbm1 \
tree \
/browser/opt/helium-bin.deb && \
ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && \
echo $TZ > /etc/timezone && \
cd /usr/bin && \
ln -snf helium chromium && \
ln -snf helium chrome && \
cp -r /ffmpeg-static/opt/* /usr/bin
# The very long line is the deps for the agent-browser
# Useradd and some micromamba stuff
RUN useradd --create-home --shell /bin/bash sandbox && \
echo "${MAMBA_USER}" > '/etc/arg_mamba_user' && \
chmod -R a+rwx '/home' '/etc/arg_mamba_user' && \
/usr/local/bin/_dockerfile_setup_root_prefix.sh
# Source micromamba according to dash or bash
RUN echo '' >> /home/sandbox/.bashrc && \
echo '# Micromamba' >> /home/sandbox/.bashrc && \
echo 'source /usr/local/bin/_activate_current_env.sh' >> /home/sandbox/.bashrc && \
echo '' >> /home/sandbox/.profile && \
echo '# Micromamba' >> /home/sandbox/.profile && \
tee -a /home/sandbox/.profile > /dev/null << 'EOF'
if [ -n "$BASH_VERSION" ]; then
:
else
eval "$(micromamba shell hook --shell dash)"
micromamba activate base
fi
EOF
# Setup Homebrew
RUN --mount=type=bind,from=brew,source=/,target=/brew \
--mount=type=tmpfs,dst=/tmp \
mkdir -p /tmp/homebrew && \
mkdir -p /home/linuxbrew && \
tar --zstd -xvf /brew/usr/share/homebrew.tar.zst -C /tmp/homebrew && \
cp -R -n /tmp/homebrew/home/linuxbrew/.linuxbrew /home/linuxbrew && \
rm -rf /home/linuxbrew/.linuxbrew/Homebrew/.git && \
chown -R 1000:1000 /home/linuxbrew && \
echo '' >> /home/sandbox/.bashrc && \
echo '# Homebrew' >> /home/sandbox/.bashrc && \
echo 'eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"' >> /home/sandbox/.bashrc && \
echo '' >> /home/sandbox/.profile && \
echo '# Homebrew' >> /home/sandbox/.profile && \
echo 'eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"' >> /home/sandbox/.profile
# Install required npm packages
RUN --mount=type=tmpfs,dst=/tmp \
--mount=type=tmpfs,dst=/root/.npm \
npm i -g clawhub agent-browser
# Now entered the target user
USER sandbox
# poppler removed from here, moved to deb
# Install required brew packages
RUN --mount=type=tmpfs,dst=/home/sandbox/.cache \
/home/linuxbrew/.linuxbrew/bin/brew tap steipete/tap && \
/home/linuxbrew/.linuxbrew/bin/brew install steipete/tap/goplaces uv && \
rm -rf /home/linuxbrew/.linuxbrew/Homebrew/.git
# Setup Micromamba
RUN micromamba config append channels conda-forge && \
micromamba config set channel_priority strict && \
micromamba install -n base python=3.14 -y && \
micromamba clean --all --yes
# Install required Python packages
RUN --mount=type=tmpfs,dst=/home/sandbox/.cache \
/home/linuxbrew/.linuxbrew/bin/uv pip install --link-mode copy --python /opt/conda torch --index-url https://download.pytorch.org/whl/cpu &&\
/home/linuxbrew/.linuxbrew/bin/uv pip install --link-mode copy --python /opt/conda whisper-ctranslate2 opendataloader-pdf yt-dlp
RUN mkdir -p ~/.agent-browser && \
tee ~/.agent-browser/config.json << EOF
{
"executablePath": "/opt/helium/helium"
}
EOF
# Inject info for agents
RUN echo "" && \
tee -a /home/sandbox/.profile /home/sandbox/.bashrc > /dev/null << 'EOF'
# Hey Agents! this file `.profile` or `.bashrc` should symlinked to the versions in `/home/sandbox/` (check with ls -al at your workspace),
# you SHOULD run those two commends if this is not the case:
# ln -sf /home/sandbox/.profile /workspace/.profile
# ln -sf /home/sandbox/.bashrc /workspace/.bashrc
# After that, you should add `.bashrc` `.profile` to `.gitignore`.
# You SHOULD NOT remove the symlink or edit the symlinked files, because it will eventually become outdate or reset during sandbox recreation, let the sandbox creator(me, the one that leavng this message!) maintain the base image's setting life cycle will make your work easier!
# doing a temporary tests by modifing the underlying files is OKAY, but you should know the changes will lost soon.
# You could to use pip, uv, brew to install things, but it will eventually lost after container recreation, make sure you've added `.local` `.cache`, `.npm` to `.gitignore`; discuss with your owner if extending `.gitignore` needed, because in the sandbox, your `$HOME` is your workspace, many programs will leaving trash when using, and it will dirty your git directory.
# Using `apt` related commends is not possible, but you could run `apt list --installed` to diagnostic the problems.
# Tell the owners if: 1. some tools should package to the base sandbox image. 2. You found the problems that can only fixed my modifing the sandbox image (Dockerfile)
EOF
WORKDIR /home/sandbox
CMD ["sleep", "infinity"]