docparse / Dockerfile
misukisu's picture
Update Dockerfile
74fa4cd verified
Raw
History Blame
1.8 kB
# ------------------------------------------------------------------------------
# 1. Builder Stage (Uses modern Rust 1.x stable with 2024 Edition support)
# ------------------------------------------------------------------------------
FROM rust:1-slim-bookworm AS builder
WORKDIR /app
RUN apt-get update && apt-get install -y --no-install-recommends \
pkg-config \
libssl-dev \
ca-certificates \
&& rm -rf /var/lib/apt/lists/*
# Cache dependency builds using skeleton manifests
COPY Cargo.toml ./
RUN mkdir src && echo "fn main() {}" > src/main.rs
RUN cargo build --release
RUN rm -rf src
# Copy real application source code and compile final binary
COPY src ./src
RUN touch src/main.rs && cargo build --release
# ------------------------------------------------------------------------------
# 2. Runtime Stage
# ------------------------------------------------------------------------------
FROM debian:bookworm-slim AS runtime
RUN apt-get update && apt-get install -y --no-install-recommends \
ca-certificates \
libssl3 \
curl \
&& rm -rf /var/lib/apt/lists/*
# Non-root user setup (UID 1000 strictly required by Hugging Face Spaces)
RUN useradd -m -u 1000 appuser
# Prepare writable storage directory for Tantivy indices
RUN mkdir -p /data/index && chown -R appuser:appuser /data
WORKDIR /app
# Copy compiled binary from builder
COPY --from=builder /app/target/release/rust-mcp-search /usr/local/bin/rust-mcp-search
ENV PORT=7860 \
HOST=0.0.0.0 \
MCP_TRANSPORT=http \
DATA_DIR=/data/index \
RUST_LOG=info
# Switch to non-root user
USER 1000
EXPOSE 7860
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
CMD curl -f http://localhost:${PORT}/health || exit 1
ENTRYPOINT ["/usr/local/bin/rust-mcp-search"]