161 lines
6.7 KiB
Text
161 lines
6.7 KiB
Text
# build to "agent-sandbox:slim"
|
|
|
|
# Import Homebrew
|
|
FROM scratch AS brew
|
|
COPY --from=ghcr.io/ublue-os/brew:latest /system_files /
|
|
|
|
# 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=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 \
|
|
tree \
|
|
ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && \
|
|
echo $TZ > /etc/timezone && \
|
|
cp -r /ffmpeg-static/opt/* /usr/bin
|
|
|
|
# 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
|
|
|
|
# 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 opendataloader-pdf yt-dlp
|
|
|
|
WORKDIR /home/sandbox
|
|
|
|
CMD ["sleep", "infinity"]
|