mirror of
https://github.com/Significant-Gravitas/AutoGPT.git
synced 2026-04-08 03:00:28 -04:00
## Summary - On **amd64**: keep `agent-browser install` (Chrome for Testing — pinned version tested with Playwright) + restore runtime libs - On **arm64**: install system `chromium` package (Chrome for Testing has no ARM64 binary) + skip `agent-browser install` - An entrypoint script sets `AGENT_BROWSER_EXECUTABLE_PATH=/usr/bin/chromium` at container startup on arm64 (detected via presence of `/usr/bin/chromium`); on amd64 the var is left unset so agent-browser uses Chrome for Testing as before **Why not system chromium on amd64?** `agent-browser install` downloads a specific Chrome for Testing version pinned to the Playwright version in use. Using whatever Debian ships on amd64 could cause protocol compatibility issues. Introduced by #12301 (cc @Significant-Gravitas/zamil-majdy) ## Test plan - [ ] `docker compose up --build` succeeds on ARM64 (Apple Silicon) - [ ] `docker compose up --build` succeeds on x86_64 - [ ] Copilot browser tools (`browser_navigate`, `browser_act`, `browser_screenshot`) work in a Copilot session on both architectures --------- Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Co-authored-by: Zamil Majdy <zamil.majdy@agpt.co>
178 lines
7.2 KiB
Docker
178 lines
7.2 KiB
Docker
# ============================ DEPENDENCY BUILDER ============================ #
|
|
|
|
FROM debian:13-slim AS builder
|
|
|
|
# Set environment variables
|
|
ENV PYTHONDONTWRITEBYTECODE=1
|
|
ENV PYTHONUNBUFFERED=1
|
|
ENV DEBIAN_FRONTEND=noninteractive
|
|
|
|
WORKDIR /app
|
|
|
|
RUN echo 'Acquire::http::Pipeline-Depth 0;\nAcquire::http::No-Cache true;\nAcquire::BrokenProxy true;\n' > /etc/apt/apt.conf.d/99fixbadproxy
|
|
|
|
# Install Node.js repository key and setup
|
|
RUN apt-get update --allow-releaseinfo-change --fix-missing \
|
|
&& apt-get install -y curl ca-certificates gnupg \
|
|
&& mkdir -p /etc/apt/keyrings \
|
|
&& curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg \
|
|
&& echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_20.x nodistro main" | tee /etc/apt/sources.list.d/nodesource.list
|
|
|
|
# Update package list and install Python, Node.js, and build dependencies
|
|
RUN apt-get update \
|
|
&& apt-get install -y \
|
|
python3.13 \
|
|
python3.13-dev \
|
|
python3.13-venv \
|
|
python3-pip \
|
|
build-essential \
|
|
libpq5 \
|
|
libz-dev \
|
|
libssl-dev \
|
|
postgresql-client \
|
|
nodejs \
|
|
&& rm -rf /var/lib/apt/lists/*
|
|
|
|
ENV POETRY_HOME=/opt/poetry
|
|
ENV POETRY_NO_INTERACTION=1
|
|
ENV POETRY_VIRTUALENVS_CREATE=true
|
|
ENV POETRY_VIRTUALENVS_IN_PROJECT=true
|
|
ENV PATH=/opt/poetry/bin:$PATH
|
|
|
|
RUN pip3 install poetry --break-system-packages
|
|
|
|
# Copy and install dependencies
|
|
COPY autogpt_platform/autogpt_libs /app/autogpt_platform/autogpt_libs
|
|
COPY autogpt_platform/backend/poetry.lock autogpt_platform/backend/pyproject.toml /app/autogpt_platform/backend/
|
|
WORKDIR /app/autogpt_platform/backend
|
|
RUN poetry install --no-ansi --no-root
|
|
|
|
# Generate Prisma client
|
|
COPY autogpt_platform/backend/schema.prisma ./
|
|
COPY autogpt_platform/backend/backend/data/partial_types.py ./backend/data/partial_types.py
|
|
COPY autogpt_platform/backend/scripts/gen_prisma_types_stub.py ./scripts/
|
|
RUN poetry run prisma generate && poetry run gen-prisma-stub
|
|
|
|
# =============================== DB MIGRATOR =============================== #
|
|
|
|
# Lightweight migrate stage - only needs Prisma CLI, not full Python environment
|
|
FROM debian:13-slim AS migrate
|
|
|
|
WORKDIR /app/autogpt_platform/backend
|
|
|
|
ENV DEBIAN_FRONTEND=noninteractive
|
|
|
|
# Install only what's needed for prisma migrate: Node.js and minimal Python for prisma-python
|
|
RUN apt-get update && apt-get install -y --no-install-recommends \
|
|
python3.13 \
|
|
python3-pip \
|
|
ca-certificates \
|
|
&& rm -rf /var/lib/apt/lists/*
|
|
|
|
# Copy Node.js from builder (needed for Prisma CLI)
|
|
COPY --from=builder /usr/bin/node /usr/bin/node
|
|
COPY --from=builder /usr/lib/node_modules /usr/lib/node_modules
|
|
COPY --from=builder /usr/bin/npm /usr/bin/npm
|
|
|
|
# Copy Prisma binaries
|
|
COPY --from=builder /root/.cache/prisma-python/binaries /root/.cache/prisma-python/binaries
|
|
|
|
# Install prisma-client-py directly (much smaller than copying full venv)
|
|
RUN pip3 install prisma>=0.15.0 --break-system-packages
|
|
|
|
COPY autogpt_platform/backend/schema.prisma ./
|
|
COPY autogpt_platform/backend/backend/data/partial_types.py ./backend/data/partial_types.py
|
|
COPY autogpt_platform/backend/scripts/gen_prisma_types_stub.py ./scripts/
|
|
COPY autogpt_platform/backend/migrations ./migrations
|
|
|
|
# ============================== BACKEND SERVER ============================== #
|
|
|
|
FROM debian:13-slim AS server
|
|
|
|
WORKDIR /app
|
|
|
|
ENV DEBIAN_FRONTEND=noninteractive
|
|
|
|
# Install Python, FFmpeg, ImageMagick, and CLI tools for agent use.
|
|
# bubblewrap provides OS-level sandbox (whitelist-only FS + no network)
|
|
# for the bash_exec MCP tool (fallback when E2B is not configured).
|
|
# Using --no-install-recommends saves ~650MB by skipping unnecessary deps like llvm, mesa, etc.
|
|
RUN apt-get update && apt-get install -y --no-install-recommends \
|
|
python3.13 \
|
|
python3-pip \
|
|
ffmpeg \
|
|
imagemagick \
|
|
jq \
|
|
ripgrep \
|
|
tree \
|
|
bubblewrap \
|
|
&& rm -rf /var/lib/apt/lists/*
|
|
|
|
# Copy poetry (build-time only, for `poetry install --only-root` to create entry points)
|
|
COPY --from=builder /usr/local/lib/python3* /usr/local/lib/python3*
|
|
COPY --from=builder /usr/local/bin/poetry /usr/local/bin/poetry
|
|
# Copy Node.js installation for Prisma and agent-browser.
|
|
# npm/npx are symlinks in the builder (-> ../lib/node_modules/npm/bin/*-cli.js);
|
|
# COPY resolves them to regular files, breaking require() paths. Recreate as
|
|
# proper symlinks so npm/npx can find their modules.
|
|
COPY --from=builder /usr/bin/node /usr/bin/node
|
|
COPY --from=builder /usr/lib/node_modules /usr/lib/node_modules
|
|
RUN ln -s ../lib/node_modules/npm/bin/npm-cli.js /usr/bin/npm \
|
|
&& ln -s ../lib/node_modules/npm/bin/npx-cli.js /usr/bin/npx
|
|
COPY --from=builder /root/.cache/prisma-python/binaries /root/.cache/prisma-python/binaries
|
|
|
|
# Install agent-browser (Copilot browser tool) + Chromium.
|
|
# On amd64: install runtime libs + run `agent-browser install` to download
|
|
# Chrome for Testing (pinned version, tested with Playwright).
|
|
# On arm64: install system chromium package — Chrome for Testing has no ARM64
|
|
# binary. AGENT_BROWSER_EXECUTABLE_PATH is set at runtime by the entrypoint
|
|
# script (below) to redirect agent-browser to the system binary.
|
|
ARG TARGETARCH
|
|
RUN apt-get update \
|
|
&& if [ "$TARGETARCH" = "arm64" ]; then \
|
|
apt-get install -y --no-install-recommends chromium fonts-liberation; \
|
|
else \
|
|
apt-get install -y --no-install-recommends \
|
|
libnss3 libnspr4 libatk1.0-0 libatk-bridge2.0-0 libcups2 libdrm2 \
|
|
libdbus-1-3 libxkbcommon0 libatspi2.0-0t64 libxcomposite1 libxdamage1 \
|
|
libxfixes3 libxrandr2 libgbm1 libasound2t64 libpango-1.0-0 libcairo2 \
|
|
libx11-6 libx11-xcb1 libxcb1 libxext6 libglib2.0-0t64 \
|
|
fonts-liberation libfontconfig1; \
|
|
fi \
|
|
&& rm -rf /var/lib/apt/lists/* \
|
|
&& npm install -g agent-browser \
|
|
&& ([ "$TARGETARCH" = "arm64" ] || agent-browser install) \
|
|
&& rm -rf /tmp/* /root/.npm
|
|
|
|
# On arm64 the system chromium is at /usr/bin/chromium; set
|
|
# AGENT_BROWSER_EXECUTABLE_PATH so agent-browser's daemon uses it instead of
|
|
# Chrome for Testing (which has no ARM64 binary). On amd64 the variable is left
|
|
# unset so agent-browser uses the Chrome for Testing binary it downloaded above.
|
|
RUN printf '#!/bin/sh\n[ -x /usr/bin/chromium ] && export AGENT_BROWSER_EXECUTABLE_PATH=/usr/bin/chromium\nexec "$@"\n' \
|
|
> /usr/local/bin/entrypoint.sh \
|
|
&& chmod +x /usr/local/bin/entrypoint.sh
|
|
|
|
WORKDIR /app/autogpt_platform/backend
|
|
|
|
# Copy only the .venv from builder (not the entire /app directory)
|
|
# The .venv includes the generated Prisma client
|
|
COPY --from=builder /app/autogpt_platform/backend/.venv ./.venv
|
|
ENV PATH="/app/autogpt_platform/backend/.venv/bin:$PATH"
|
|
|
|
# Copy dependency files + autogpt_libs (path dependency)
|
|
COPY autogpt_platform/autogpt_libs /app/autogpt_platform/autogpt_libs
|
|
COPY autogpt_platform/backend/poetry.lock autogpt_platform/backend/pyproject.toml ./
|
|
|
|
# Copy backend code + docs (for Copilot docs search)
|
|
COPY autogpt_platform/backend ./
|
|
COPY docs /app/docs
|
|
# Install the project package to create entry point scripts in .venv/bin/
|
|
# (e.g., rest, executor, ws, db, scheduler, notification - see [tool.poetry.scripts])
|
|
RUN POETRY_VIRTUALENVS_CREATE=true POETRY_VIRTUALENVS_IN_PROJECT=true \
|
|
poetry install --no-ansi --only-root
|
|
|
|
ENV PORT=8000
|
|
|
|
ENTRYPOINT ["/usr/local/bin/entrypoint.sh"]
|
|
CMD ["rest"]
|