agent-sandbox/slim-fedora/Containerfile
XLion 7e60ab2ae9
All checks were successful
slim-fedora / build-and-push (push) Successful in 26m22s
slim-fedora / build (push) Successful in 0s
add sandbox hint
2026-08-22 23:53:24 +08:00

138 lines
4.9 KiB
Docker

# build to "agent-sandbox:slim-fedora"
# Import Homebrew
FROM scratch AS brew
COPY --from=ghcr.io/ublue-os/brew:latest /system_files /
# Import Micromamba
FROM registry.hub.docker.com/mambaorg/micromamba:latest AS micromamba
FROM quay.io/fedora/fedora:44
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"
# 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
RUN --mount=type=tmpfs,dst=/var/cache \
dnf -y install \
https://download1.rpmfusion.org/free/fedora/rpmfusion-free-release-$(rpm -E %fedora).noarch.rpm \
https://download1.rpmfusion.org/nonfree/fedora/rpmfusion-nonfree-release-$(rpm -E %fedora).noarch.rpm &&\
dnf -y install ffmpeg x264 x264-libs --allowerasing &&\
dnf -y group install development-tools && \
dnf -y install intel-media-driver libva-utils which file tree bind-utils curl wget git git-lfs ripgrep jq yq poppler \
procps-ng psmisc lsof strace iproute iputils fd-find ShellCheck rsync \
default-fonts-cjk default-fonts-core-emoji \
just \
python3-pip nodejs24-bin java-latest-openjdk
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && \
echo $TZ > /etc/timezone
# 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 && \
usermod -aG wheel sandbox && \
echo "sandbox ALL=(ALL:ALL) NOPASSWD:ALL" | tee /etc/sudoers.d/NOPASSWD && \
chmod 0440 /etc/sudoers.d/NOPASSWD
# Source micromamba according to dash or bash
RUN printf '%s\n' \
'' \
'# Micromamba' \
'source /usr/local/bin/_activate_current_env.sh' \
>> /home/sandbox/.bashrc && \
printf '%s\n' \
'' \
'# Micromamba' \
'if [ -n "$BASH_VERSION" ]; then' \
' :' \
'else' \
' eval "$(micromamba shell hook --shell dash)"' \
' micromamba activate base' \
'fi' \
>> /home/sandbox/.profile
# 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
# Now entered the target user
USER sandbox
# Install required brew packages
RUN /home/linuxbrew/.linuxbrew/bin/brew install openclaw/tap/goplaces openclaw/tap/gogcli && \
/home/linuxbrew/.linuxbrew/bin/brew install uv gh ruff ty && \
/home/linuxbrew/.linuxbrew/bin/brew cleanup --prune=all && \
rm -rf /home/linuxbrew/.linuxbrew/Homebrew/.git /home/sandbox/.cache
# 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 /home/linuxbrew/.linuxbrew/bin/uv pip install \
--link-mode copy \
--no-cache \
--python /opt/conda \
httpie \
orjson \
pymupdf \
pypdf \
opendataloader-pdf \
yt-dlp \
youtube-transcript-api \
huggingface-hub \
'markitdown[pdf,docx,pptx,xls,xlsx,youtube-transcription]' \
psutil \
tenacity \
tomlkit \
ruamel.yaml \
jsonschema \
jmespath \
pathspec \
zstandard \
pytest
COPY build_info_inject.sh /tmp/build_info_inject.sh
COPY sandbox.md /sandbox.md
USER root
RUN /tmp/build_info_inject.sh && \
cat /tmp/build | tee -a /sandbox.md
USER sandbox
WORKDIR /home/sandbox
CMD ["sleep", "infinity"]