The platform for continuously improving AI agents.
# syntax=docker/dockerfile:1
# Build unified Rust server binary against official prebuilt DuckDB v2.0.0.
# Context is the repo root: docker build -f collector/Dockerfile .
# The Console calls this process over ConnectRPC.
FROM rust:1-bookworm AS rust-builder
COPY --from=bufbuild/buf:1 /usr/local/bin/buf /usr/local/bin/buf
RUN apt-get update && apt-get install -y --no-install-recommends \
protobuf-compiler \
cmake \
g++ \
pkg-config \
libssl-dev \
ca-certificates \
curl \
&& rm -rf /var/lib/apt/lists/*
ARG TARGETARCH
RUN case "$TARGETARCH" in \
amd64|arm64) ;; \
*) echo "unsupported TARGETARCH $TARGETARCH" >&2; exit 1 ;; \
esac \
&& mkdir -p /opt/duckdb \
&& curl -fsSL "https://install.duckdb.org/v2.0.0/duckdb-shared-libs-linux-$TARGETARCH.tar.gz" \
| tar -xzf - -C /opt/duckdb \
&& cp /opt/duckdb/libduckdb.so /usr/local/lib/libduckdb.so \
&& ldconfig
WORKDIR /app
COPY Cargo.toml Cargo.lock buf.yaml buf.lock ./
COPY api/ ./api/
COPY scripts/connect_rust.rs ./scripts/connect_rust.rs
COPY packages/ ./packages/
ENV DUCKDB_LIB_DIR=/opt/duckdb \
DUCKDB_INCLUDE_DIR=/opt/duckdb
RUN --mount=type=cache,target=/usr/local/cargo/registry \
--mount=type=cache,target=/app/target \
cargo build --release --no-default-features -p server \
&& cp /app/target/release/server /app/server-bin
# Official Caddy release binaries are static, so the alpine image's binary runs on glibc.
FROM caddy:2-alpine AS caddy-bin
# Stage 3: Lean runtime image. One image runs both `server` and the Caddy sidecar.
FROM debian:bookworm-slim
RUN apt-get update && apt-get install -y --no-install-recommends \
ca-certificates \
curl \
libstdc++6 \
&& rm -rf /var/lib/apt/lists/*
COPY --from=rust-builder /opt/duckdb/libduckdb.so /usr/local/lib/libduckdb.so
RUN ldconfig
COPY --from=rust-builder /app/server-bin /usr/local/bin/server
COPY --from=caddy-bin /usr/bin/caddy /usr/bin/caddy
COPY collector/Caddyfile /etc/caddy/Caddyfile
RUN caddy version && mkdir -p /data
EXPOSE 8080
CMD ["/usr/local/bin/server"]