feat(dev): add containerized development environment
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
128b30cdf1
commit
20f857a55a
6 changed files with 385 additions and 24 deletions
119
Dockerfile
119
Dockerfile
|
|
@ -1,38 +1,109 @@
|
|||
# syntax=docker/dockerfile:1
|
||||
|
||||
# ── Stage 1: Build ────────────────────────────────────────────
|
||||
FROM rust:1.93-slim-bookworm AS builder
|
||||
FROM rust:1.93-slim AS builder
|
||||
|
||||
WORKDIR /app
|
||||
COPY Cargo.toml Cargo.lock ./
|
||||
COPY src/ src/
|
||||
|
||||
# Install build dependencies
|
||||
RUN apt-get update && apt-get install -y \
|
||||
pkg-config \
|
||||
libssl-dev \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
# 1. Copy manifests to cache dependencies
|
||||
COPY Cargo.toml Cargo.lock ./
|
||||
# Create dummy main.rs to build dependencies
|
||||
RUN mkdir src && echo "fn main() {}" > src/main.rs
|
||||
RUN cargo build --release --locked
|
||||
RUN rm -rf src
|
||||
|
||||
# 2. Copy source code
|
||||
COPY . .
|
||||
# Touch main.rs to force rebuild
|
||||
RUN touch src/main.rs
|
||||
RUN cargo build --release --locked && \
|
||||
strip target/release/zeroclaw
|
||||
|
||||
# ── Stage 2: Runtime (distroless, runs as root for /data write access) ──
|
||||
FROM gcr.io/distroless/cc-debian12
|
||||
# ── Stage 2: Permissions & Config Prep ───────────────────────
|
||||
FROM busybox:latest AS permissions
|
||||
# Create directory structure (simplified workspace path)
|
||||
RUN mkdir -p /zeroclaw-data/.zeroclaw /zeroclaw-data/workspace
|
||||
|
||||
# Create minimal config for PRODUCTION (allows binding to public interfaces)
|
||||
# NOTE: Provider configuration must be done via environment variables at runtime
|
||||
RUN cat > /zeroclaw-data/.zeroclaw/config.toml << 'EOF'
|
||||
workspace_dir = "/zeroclaw-data/workspace"
|
||||
config_path = "/zeroclaw-data/.zeroclaw/config.toml"
|
||||
api_key = ""
|
||||
default_provider = "openrouter"
|
||||
default_model = "anthropic/claude-sonnet-4-20250514"
|
||||
default_temperature = 0.7
|
||||
|
||||
[gateway]
|
||||
port = 3000
|
||||
host = "[::]"
|
||||
allow_public_bind = true
|
||||
EOF
|
||||
|
||||
RUN chown -R 65534:65534 /zeroclaw-data
|
||||
|
||||
# ── Stage 3: Development Runtime (Debian) ────────────────────
|
||||
FROM debian:bookworm-slim AS dev
|
||||
|
||||
# Install runtime dependencies + basic debug tools
|
||||
RUN apt-get update && apt-get install -y \
|
||||
ca-certificates \
|
||||
openssl \
|
||||
curl \
|
||||
git \
|
||||
iputils-ping \
|
||||
vim \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
COPY --from=permissions /zeroclaw-data /zeroclaw-data
|
||||
COPY --from=builder /app/target/release/zeroclaw /usr/local/bin/zeroclaw
|
||||
|
||||
# Default workspace and data directory (owned by nonroot user)
|
||||
VOLUME ["/data"]
|
||||
ENV ZEROCLAW_WORKSPACE=/data/workspace
|
||||
# Overwrite minimal config with DEV template (Ollama defaults)
|
||||
COPY dev/config.template.toml /zeroclaw-data/.zeroclaw/config.toml
|
||||
RUN chown 65534:65534 /zeroclaw-data/.zeroclaw/config.toml
|
||||
|
||||
# ── Environment variable configuration (Docker-native setup) ──
|
||||
# These can be overridden at runtime via docker run -e or docker-compose
|
||||
#
|
||||
# Required:
|
||||
# API_KEY or ZEROCLAW_API_KEY - Your LLM provider API key
|
||||
#
|
||||
# Optional:
|
||||
# PROVIDER or ZEROCLAW_PROVIDER - LLM provider (default: openrouter)
|
||||
# Options: openrouter, openai, anthropic, ollama
|
||||
# ZEROCLAW_MODEL - Model to use (default: anthropic/claude-sonnet-4-20250514)
|
||||
# PORT or ZEROCLAW_GATEWAY_PORT - Gateway port (default: 3000)
|
||||
#
|
||||
# Example:
|
||||
# docker run -e API_KEY=sk-... -e PROVIDER=openrouter zeroclaw/zeroclaw
|
||||
# Environment setup
|
||||
# Use consistent workspace path
|
||||
ENV ZEROCLAW_WORKSPACE=/zeroclaw-data/workspace
|
||||
ENV HOME=/zeroclaw-data
|
||||
# Defaults for local dev (Ollama) - matches config.template.toml
|
||||
ENV PROVIDER="ollama"
|
||||
ENV ZEROCLAW_MODEL="llama3.2"
|
||||
ENV ZEROCLAW_GATEWAY_PORT=3000
|
||||
|
||||
# Note: API_KEY is intentionally NOT set here to avoid confusion.
|
||||
# It is set in config.toml as the Ollama URL.
|
||||
|
||||
WORKDIR /zeroclaw-data
|
||||
USER 65534:65534
|
||||
EXPOSE 3000
|
||||
|
||||
ENTRYPOINT ["zeroclaw"]
|
||||
CMD ["gateway"]
|
||||
CMD ["gateway", "--port", "3000", "--host", "[::]"]
|
||||
|
||||
# ── Stage 4: Production Runtime (Distroless) ─────────────────
|
||||
FROM gcr.io/distroless/cc-debian12:nonroot AS release
|
||||
|
||||
COPY --from=builder /app/target/release/zeroclaw /usr/local/bin/zeroclaw
|
||||
COPY --from=permissions /zeroclaw-data /zeroclaw-data
|
||||
|
||||
# Environment setup
|
||||
ENV ZEROCLAW_WORKSPACE=/zeroclaw-data/workspace
|
||||
ENV HOME=/zeroclaw-data
|
||||
# Defaults for prod (OpenRouter)
|
||||
ENV PROVIDER="openrouter"
|
||||
ENV ZEROCLAW_MODEL="anthropic/claude-sonnet-4-20250514"
|
||||
ENV ZEROCLAW_GATEWAY_PORT=3000
|
||||
|
||||
# API_KEY must be provided at runtime!
|
||||
|
||||
WORKDIR /zeroclaw-data
|
||||
USER 65534:65534
|
||||
EXPOSE 3000
|
||||
ENTRYPOINT ["zeroclaw"]
|
||||
CMD ["gateway", "--port", "3000", "--host", "[::]"]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue