picoclaw/docker/Dockerfile.heavy
2026-03-24 13:57:50 +02:00

113 lines
4 KiB
Text

# ============================================================
# Stage 1: Build picoclaw + picoclaw-launcher
# ============================================================
FROM golang:1.26.0-alpine AS builder
RUN apk add --no-cache git make nodejs npm && \
npm install -g pnpm
WORKDIR /src
# Cache dependencies
COPY go.mod go.sum ./
RUN go mod download
# Copy source and build picoclaw gateway binary
COPY . .
RUN make build
# Build the launcher (frontend + backend)
RUN cd web/frontend && pnpm install --frozen-lockfile && pnpm build:backend
RUN CGO_ENABLED=0 go build -v -tags stdjson -o build/picoclaw-launcher ./web/backend
# ============================================================
# Stage 2: Node.js runtime with Python + MCP + Homebrew support
# ============================================================
FROM node:24-slim
RUN apt-get update && apt-get install -y --no-install-recommends \
ca-certificates \
curl \
git \
python3 \
python3-pip \
chromium \
jq \
tmux \
ffmpeg \
wget \
build-essential \
procps \
file \
&& curl -fsSL https://cli.github.com/packages/githubcli-archive-keyring.gpg \
| dd of=/usr/share/keyrings/githubcli-archive-keyring.gpg \
&& echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" \
| tee /etc/apt/sources.list.d/github-cli.list > /dev/null \
&& apt-get update && apt-get install -y gh \
&& rm -rf /var/lib/apt/lists/*
# Install Homebrew (requires non-root user)
ENV NONINTERACTIVE=1
RUN useradd -m -s /bin/bash linuxbrew && \
mkdir -p /home/linuxbrew/.linuxbrew && \
chown -R linuxbrew: /home/linuxbrew
USER linuxbrew
RUN /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
USER root
ENV PATH="/home/linuxbrew/.linuxbrew/bin:/home/linuxbrew/.linuxbrew/sbin:$PATH"
# Install agent-browser CLI (uses system chromium via AGENT_BROWSER_EXECUTABLE_PATH)
RUN npm install -g agent-browser
# Virtual framebuffer for headed chromium in headless container
RUN apt-get update && apt-get install -y --no-install-recommends xvfb \
&& rm -rf /var/lib/apt/lists/*
# Install GitHub Copilot CLI (headless proxy)
RUN npm install -g @github/copilot@1.0.10
# Install uv
RUN curl -LsSf https://astral.sh/uv/install.sh | sh && \
ln -s /root/.local/bin/uv /usr/local/bin/uv && \
ln -s /root/.local/bin/uvx /usr/local/bin/uvx && \
uv --version
# Install Python packages (system-wide via uv to avoid PEP 668 issues)
# atproto: Bluesky AT Protocol SDK
# moviepy: Programmatic video editing (timed text overlays, compositing)
# librosa: Audio analysis (beat detection, loudness, onset detection)
# pydub: Simple audio slicing/mixing
# srt: SRT subtitle generation for ffmpeg lyric burn-in
RUN uv pip install --system --break-system-packages atproto moviepy librosa pydub srt
# Install bsky CLI (Python wrapper around atproto SDK)
COPY docker/bsky.py /usr/local/bin/bsky
RUN sed -i 's/\r$//' /usr/local/bin/bsky && chmod +x /usr/local/bin/bsky
# Install threads CLI (Threads API wrapper)
COPY docker/threads.py /usr/local/bin/threads
RUN sed -i 's/\r$//' /usr/local/bin/threads && chmod +x /usr/local/bin/threads
# Install instagram CLI (Instagram Graph API wrapper)
COPY docker/instagram.py /usr/local/bin/instagram
RUN sed -i 's/\r$//' /usr/local/bin/instagram && chmod +x /usr/local/bin/instagram
# Health check
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
CMD wget -q --spider http://localhost:18790/health || exit 1
# Copy binaries
COPY --from=builder /src/build/picoclaw /usr/local/bin/picoclaw
COPY --from=builder /src/build/picoclaw-launcher /usr/local/bin/picoclaw-launcher
# Run onboard to create initial directories and config
RUN /usr/local/bin/picoclaw onboard
# Copy default workspace
COPY workspace/ /root/.picoclaw/workspace/
COPY docker/entrypoint.sh /entrypoint.sh
RUN sed -i 's/\r$//' /entrypoint.sh && chmod +x /entrypoint.sh
ENTRYPOINT ["/entrypoint.sh"]
CMD []