opencrates 0.1.1

AI-powered Rust crate generator and registry with advanced template system
Documentation
# Multi-stage build for OpenCrates
# Build stage
FROM rust:1.75 as builder

WORKDIR /app

# Copy manifests
COPY Cargo.toml Cargo.lock ./

# Copy source
COPY src ./src

# Build release
RUN cargo build --release

FROM debian:bookworm-slim

RUN apt-get update && \
    apt-get install -y ca-certificates python3 python3-pip && \
    rm -rf /var/lib/apt/lists/*

RUN python3 -m pip install aider-chat

COPY --from=builder /app/target/release/opencrates /usr/local/bin/opencrates

EXPOSE 8080

CMD ["opencrates", "server"]

# Runtime stage
FROM debian:bookworm-slim

# Install runtime dependencies
RUN apt-get update && apt-get install -y \
    ca-certificates \
    libssl3 \
    libpq5 \
    curl \
    && rm -rf /var/lib/apt/lists/*

# Create app user
RUN useradd -m -u 1000 opencrates

# Create necessary directories
RUN mkdir -p /app /app/config /app/logs /app/storage \
    && chown -R opencrates:opencrates /app

# Set working directory
WORKDIR /app

# Copy binary from builder
COPY --from=builder /app/target/release/opencrates /usr/local/bin/opencrates
COPY --from=builder --chown=opencrates:opencrates /app/config ./config

# Copy configuration templates
COPY --chown=opencrates:opencrates config/production.toml ./config/
COPY --chown=opencrates:opencrates scripts/entrypoint.sh ./

# Make entrypoint executable
RUN chmod +x entrypoint.sh

# Switch to app user
USER opencrates

# Expose ports
EXPOSE 8080 9090

# Health check
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
    CMD curl -f http://localhost:8080/health || exit 1

# Set environment variables
ENV RUST_LOG=info \
    RUST_BACKTRACE=1 \
    OPENCRATES_CONFIG_PATH=/app/config/production.toml \
    OPENCRATES_STORAGE_PATH=/app/storage \
    OPENCRATES_LOG_PATH=/app/logs

# Entrypoint
ENTRYPOINT ["./entrypoint.sh"]
CMD ["serve"]

# Development stage (optional)
FROM builder AS development

# Install development tools
RUN apt-get update && apt-get install -y \
    bash \
    fish \
    git \
    vim \
    htop \
    && rm -rf /var/lib/apt/lists/*

# Install cargo tools
RUN cargo install cargo-watch cargo-audit cargo-outdated

# Set working directory
WORKDIR /app

# Switch to rustuser
USER rustuser

# Development command
CMD ["cargo", "run"]

# Testing stage
FROM builder AS testing

# Copy test data
COPY tests/ ./tests/

# Run tests
RUN cargo test --release

# Benchmark stage
FROM builder AS benchmark

# Install benchmarking tools
RUN cargo install cargo-criterion

# Run benchmarks
RUN cargo bench

# Documentation stage
FROM builder AS docs

# Generate documentation
RUN cargo doc --no-deps --document-private-items

# Copy docs to a volume
VOLUME ["/app/target/doc"]