1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
# Multi-stage build for optimal Docker image size
FROM rust:1.70-slim as builder
# Install build dependencies
RUN apt-get update && apt-get install -y \
pkg-config \
libssl-dev \
&& rm -rf /var/lib/apt/lists/*
# Create app directory
WORKDIR /app
# Copy dependency files first for better layer caching
COPY Cargo.toml Cargo.lock ./
# Create dummy main.rs to build dependencies
RUN mkdir src && echo "fn main() {}" > src/main.rs
# Build dependencies (cached layer)
RUN cargo build --release --bin rustchain && rm -rf src
# Copy actual source code
COPY src ./src
COPY examples ./examples
COPY docs ./docs
# Build the actual application
RUN cargo build --release --bin rustchain
# Runtime stage with minimal image
FROM debian:bookworm-slim
# Install runtime dependencies
RUN apt-get update && apt-get install -y \
ca-certificates \
&& rm -rf /var/lib/apt/lists/*
# Create non-root user for security
RUN useradd -r -s /bin/false rustchain
# Copy binary from builder stage
COPY --from=builder /app/target/release/rustchain /usr/local/bin/rustchain
# Copy example configurations
COPY --from=builder /app/examples /opt/rustchain/examples
# Set ownership and permissions
RUN chown root:root /usr/local/bin/rustchain && \
chmod 755 /usr/local/bin/rustchain
# Create working directory for user
WORKDIR /workspace
RUN chown rustchain:rustchain /workspace
# Switch to non-root user
USER rustchain
# Set environment variables
ENV RUST_LOG=info
ENV RUSTCHAIN_CONFIG_PATH=/workspace/rustchain.toml
# Health check
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
CMD rustchain --version || exit 1
# Default command
CMD ["rustchain", "--help"]
# Labels for metadata
LABEL org.opencontainers.image.title="Rustchain Community Edition" \
org.opencontainers.image.description="Production-ready AI agent framework built in Rust" \
org.opencontainers.image.vendor="Rustchain Community" \
org.opencontainers.image.url="https://rustchain.dev" \
org.opencontainers.image.documentation="https://docs.rs/rustchain-community" \
org.opencontainers.image.source="https://github.com/Michael-A-Kuykendall/rustchain-community" \
org.opencontainers.image.licenses="MIT OR Apache-2.0"