mirror of
https://github.com/0xMassi/webclaw.git
synced 2026-04-25 00:06:21 +02:00
v0.3.13 switched ENTRYPOINT to ["webclaw"] to make `docker run IMAGE https://example.com` work. That broke a different use case: downstream Dockerfiles that `FROM ghcr.io/0xmassi/webclaw` and set their own CMD ["./setup.sh"] — the child's ./setup.sh becomes arg to webclaw, which tries to fetch it as a URL and fails: fetch error: request failed: error sending request for uri (https://./setup.sh): client error (Connect) Both Dockerfile and Dockerfile.ci now use docker-entrypoint.sh which: - forwards flags (-*) and URLs (http://, https://) to `webclaw` - exec's anything else directly Test matrix (all pass locally): docker run IMAGE https://example.com → webclaw scrape ok docker run IMAGE --help → webclaw --help ok docker run IMAGE → default CMD, --help docker run IMAGE bash → bash runs FROM IMAGE + CMD ["./setup.sh"] → setup.sh runs, webclaw available Default CMD is ["webclaw", "--help"] so bare `docker run IMAGE` still prints help. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
67 lines
2.9 KiB
Docker
67 lines
2.9 KiB
Docker
# webclaw — Multi-stage Docker build
|
|
# Produces 2 binaries: webclaw (CLI) and webclaw-mcp (MCP server)
|
|
|
|
# ---------------------------------------------------------------------------
|
|
# Stage 1: Build all binaries in release mode
|
|
# ---------------------------------------------------------------------------
|
|
FROM rust:1.93-bookworm AS builder
|
|
|
|
# Build dependencies: cmake + clang for BoringSSL (wreq), pkg-config for linking
|
|
RUN apt-get update && apt-get install -y --no-install-recommends \
|
|
pkg-config \
|
|
libssl-dev \
|
|
cmake \
|
|
clang \
|
|
&& rm -rf /var/lib/apt/lists/*
|
|
|
|
WORKDIR /build
|
|
|
|
# Copy manifests + lock first for better layer caching.
|
|
# If only source changes, cargo doesn't re-download deps.
|
|
COPY Cargo.toml Cargo.lock ./
|
|
COPY crates/webclaw-core/Cargo.toml crates/webclaw-core/Cargo.toml
|
|
COPY crates/webclaw-fetch/Cargo.toml crates/webclaw-fetch/Cargo.toml
|
|
COPY crates/webclaw-llm/Cargo.toml crates/webclaw-llm/Cargo.toml
|
|
COPY crates/webclaw-pdf/Cargo.toml crates/webclaw-pdf/Cargo.toml
|
|
COPY crates/webclaw-mcp/Cargo.toml crates/webclaw-mcp/Cargo.toml
|
|
COPY crates/webclaw-cli/Cargo.toml crates/webclaw-cli/Cargo.toml
|
|
|
|
# Copy .cargo config if present (optional build flags)
|
|
COPY .cargo .cargo
|
|
|
|
# Create dummy source files so cargo can resolve deps and cache them.
|
|
RUN mkdir -p crates/webclaw-core/src && echo "" > crates/webclaw-core/src/lib.rs \
|
|
&& mkdir -p crates/webclaw-fetch/src && echo "" > crates/webclaw-fetch/src/lib.rs \
|
|
&& mkdir -p crates/webclaw-llm/src && echo "" > crates/webclaw-llm/src/lib.rs \
|
|
&& mkdir -p crates/webclaw-pdf/src && echo "" > crates/webclaw-pdf/src/lib.rs \
|
|
&& mkdir -p crates/webclaw-mcp/src && echo "fn main() {}" > crates/webclaw-mcp/src/main.rs \
|
|
&& mkdir -p crates/webclaw-cli/src && echo "fn main() {}" > crates/webclaw-cli/src/main.rs
|
|
|
|
# Pre-build dependencies (this layer is cached until Cargo.toml/lock changes)
|
|
RUN cargo build --release 2>/dev/null || true
|
|
|
|
# Now copy real source and rebuild. Only the final binaries recompile.
|
|
COPY crates crates
|
|
RUN touch crates/*/src/*.rs \
|
|
&& cargo build --release
|
|
|
|
# ---------------------------------------------------------------------------
|
|
# Stage 2: Minimal runtime image
|
|
# ---------------------------------------------------------------------------
|
|
FROM ubuntu:24.04
|
|
|
|
RUN apt-get update && apt-get install -y --no-install-recommends \
|
|
ca-certificates \
|
|
&& rm -rf /var/lib/apt/lists/*
|
|
|
|
# Copy both binaries
|
|
COPY --from=builder /build/target/release/webclaw /usr/local/bin/webclaw
|
|
COPY --from=builder /build/target/release/webclaw-mcp /usr/local/bin/webclaw-mcp
|
|
|
|
# Entrypoint shim: forwards webclaw args/URL to the binary, but exec's other
|
|
# commands directly so this image can be used as a FROM base with custom CMD.
|
|
COPY docker-entrypoint.sh /usr/local/bin/docker-entrypoint.sh
|
|
RUN chmod +x /usr/local/bin/docker-entrypoint.sh
|
|
|
|
ENTRYPOINT ["docker-entrypoint.sh"]
|
|
CMD ["webclaw", "--help"]
|