ARG BUILD_FROM FROM ${BUILD_FROM} # Base image is Debian Bookworm (glibc). This avoids musl-related native module issues # that occur on Alpine (e.g. clipboard, node-llama-cpp). # Install base packages (without nodejs/npm - we'll get Node 22 from NodeSource) # build-essential provides gcc/cc needed by Homebrew for OpenClaw's brew-managed dependencies RUN apt-get update && apt-get install -y --no-install-recommends \ bash \ git \ openssh-client \ ca-certificates \ tzdata \ jq \ curl \ tar \ xz-utils \ file \ python3 \ nginx \ gnupg \ build-essential \ sudo \ vim \ nano \ fd-find \ ripgrep \ rsync \ bat \ less \ openssl \ && apt-get clean \ && rm -rf /var/lib/apt/lists/* # Install Node.js 22 LTS from NodeSource (Debian Bookworm ships Node 18, but OpenClaw requires 20+) # Use explicit keyring + apt source instead of setup_22.x pipe script for deterministic builds. RUN mkdir -p /etc/apt/keyrings \ && curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key \ | gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg \ && chmod 644 /etc/apt/keyrings/nodesource.gpg \ && echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_22.x nodistro main" \ > /etc/apt/sources.list.d/nodesource.list \ && apt-get update \ && apt-get install -y --no-install-recommends nodejs \ && NODE_VERSION="$(node -v)" \ && echo "$NODE_VERSION" \ && echo "$NODE_VERSION" | grep -E '^v22\.' \ && rm -f /etc/apt/sources.list.d/nodesource.list /etc/apt/keyrings/nodesource.gpg \ && apt-get clean \ && rm -rf /var/lib/apt/lists/* # Install ttyd (web terminal) - not in Debian repos, download binary # Docker TARGETARCH: amd64, arm64, arm/v7 → ttyd filenames: x86_64, aarch64, armhf ARG TARGETARCH RUN ARCH=$(echo ${TARGETARCH:-$(dpkg --print-architecture)} | sed 's|arm64|aarch64|;s|arm/v7|armhf|;s|armv7|armhf|;s|amd64|x86_64|') \ && echo "Downloading ttyd for arch: ${ARCH}" \ && curl -fsSL "https://github.com/tsl0922/ttyd/releases/download/1.7.7/ttyd.${ARCH}" -o /usr/local/bin/ttyd \ && chmod +x /usr/local/bin/ttyd RUN node -v && npm -v # Install pnpm globally (required by some OpenClaw skills like clawhub) RUN npm install -g pnpm && pnpm -v # Install Chromium for website automation tasks # Includes necessary dependencies for headless browser operation RUN apt-get update && apt-get install -y --no-install-recommends \ chromium \ chromium-driver \ && apt-get clean \ && rm -rf /var/lib/apt/lists/* # Install Homebrew (Linuxbrew) for OpenClaw skill dependencies # Homebrew is optional - some skills need CLI tools like gemini, aider, etc. # NOTE: Homebrew requires CPU with SSSE3 support (Intel Core 2 or newer, ~2006+) # If installation fails (e.g., older CPUs), the add-on will still work but some skills may not install ENV HOMEBREW_NO_AUTO_UPDATE=1 \ HOMEBREW_NO_INSTALL_CLEANUP=1 \ HOMEBREW_NO_ANALYTICS=1 RUN useradd -m -s /bin/bash linuxbrew \ && mkdir -p /home/linuxbrew/.linuxbrew \ && chown -R linuxbrew:linuxbrew /home/linuxbrew USER linuxbrew RUN /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" || \ (echo "WARNING: Homebrew installation failed (likely unsupported CPU - requires SSSE3). Some skills may not work." && exit 0) RUN if [ -d /home/linuxbrew/.linuxbrew/Homebrew ]; then \ cd /home/linuxbrew/.linuxbrew/Homebrew && \ git config --global --add safe.directory /home/linuxbrew/.linuxbrew/Homebrew && \ /home/linuxbrew/.linuxbrew/bin/brew update --force || true; \ fi USER root # Add Homebrew to PATH for all users (wrapper comes first to intercept root calls) # PATH is set even if brew failed - wrapper will handle missing brew gracefully ENV PATH="/usr/local/bin:/home/linuxbrew/.linuxbrew/bin:/home/linuxbrew/.linuxbrew/sbin:${PATH}" # Copy brew wrapper that allows root to run brew by delegating to linuxbrew user COPY brew-wrapper.sh /usr/local/bin/brew RUN chmod +x /usr/local/bin/brew # Verify brew is available and install gcc (needed for compiling some brew packages) # Skip if brew installation failed USER linuxbrew RUN if [ -x /home/linuxbrew/.linuxbrew/bin/brew ]; then \ /home/linuxbrew/.linuxbrew/bin/brew --version && \ /home/linuxbrew/.linuxbrew/bin/brew install gcc || true; \ else \ echo "Skipping gcc installation - Homebrew not available"; \ fi USER root # Install OpenClaw globally RUN npm config set fund false && npm config set audit false \ && npm install -g openclaw@2026.4.27 # Shell aliases and color options for interactive use RUN tee -a /etc/bash.bashrc <<'EOF' # Aliases alias bat="batcat" alias fd="fdfind" # Enable colors alias ls="ls --color=auto" alias grep="grep --color=auto" alias egrep="grep -E --color=auto" alias fgrep="grep -F --color=auto" alias diff="diff --color=auto" alias ip="ip --color=auto" if [ -z "${LS_COLORS+x}" ]; then export LS_COLORS="di=1;34:ln=1;36:so=1;pi=33:ex=1;32:bd=1;33:cd=1;33:su=1;31:sg=1;31:tw=1;34:ow=1;34" fi EOF COPY run.sh /run.sh COPY oc_config_helper.py /oc_config_helper.py COPY render_nginx.py /render_nginx.py COPY oc-cleanup.sh /usr/local/bin/oc-cleanup COPY openclaw-proxy-shim.cjs /usr/local/lib/openclaw-proxy-shim.cjs COPY nginx.conf.tpl /etc/nginx/nginx.conf.tpl COPY landing.html.tpl /etc/nginx/landing.html.tpl RUN chmod +x /run.sh /oc_config_helper.py /render_nginx.py /usr/local/bin/oc-cleanup \ && mkdir -p /run/nginx CMD [ "/run.sh" ]