11# syntax=docker/dockerfile:1
2- # ── Stage 1: install cargo-chef ───────────────────────────────────────────────
2+ # Builds a fully static musl binary — runs on any Linux, no GLIBC version requirement.
3+
4+ # ── Stage 1: install cargo-chef + musl toolchain ─────────────────────────────
35FROM rust:1-slim AS chef
46RUN apt-get update \
5- && apt-get install -y --no-install-recommends pkg-config libssl-dev \
7+ && apt-get install -y --no-install-recommends musl-tools ca-certificates \
68 && rm -rf /var/lib/apt/lists/*
9+ RUN rustup target add x86_64-unknown-linux-musl
710RUN cargo install cargo-chef --locked
811WORKDIR /build
912
@@ -15,27 +18,23 @@ RUN cargo chef prepare --recipe-path recipe.json
1518# ── Stage 3: pre-compile dependencies (cached layer) ─────────────────────────
1619FROM chef AS builder
1720COPY --from=planner /build/recipe.json recipe.json
18- RUN cargo chef cook --release -p example-eventage-claw --recipe-path recipe.json
21+ RUN cargo chef cook --release --target x86_64-unknown-linux-musl \
22+ -p example-eventage-claw --recipe-path recipe.json
1923
2024# Build the actual binary (only re-runs when source changes)
2125COPY . .
22- RUN cargo build --release -p example-eventage-claw
26+ RUN cargo build --release --target x86_64-unknown-linux-musl - p example-eventage-claw
2327
2428# ── Stage 4: minimal runtime image ────────────────────────────────────────────
25- FROM debian:12-slim AS runtime
26- RUN apt-get update \
27- && apt-get install -y --no-install-recommends ca-certificates libssl3 \
28- && rm -rf /var/lib/apt/lists/*
29+ FROM alpine:3 AS runtime
30+ RUN apk add --no-cache ca-certificates
2931
30- COPY --from=builder /build/target/release/claw /usr/local/bin/claw
32+ COPY --from=builder /build/target/x86_64-unknown-linux-musl/ release/claw /usr/local/bin/claw
3133
3234# Persistent data directory: config, skills, memory, tasks, event log.
33- # Mount a volume or bind-mount a host directory here.
3435VOLUME ["/root/.claw" ]
3536
3637EXPOSE 3000
3738
3839ENTRYPOINT ["claw" ]
39- # Override CMD to pass extra flags, e.g.:
40- # docker run ... claw --http-port 3000 --log /root/.claw/events.jsonl
4140CMD ["--no-tui" , "--http-port" , "3000" ]
0 commit comments