misukisu commited on
Commit
7ea9978
·
verified ·
1 Parent(s): 3d98e09

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +26 -48
Dockerfile CHANGED
@@ -1,60 +1,38 @@
1
- # ------------------------------------------------------------------------------
2
- # 1. Builder Stage (Uses modern Rust 1.x stable with 2024 Edition support)
3
- # ------------------------------------------------------------------------------
4
- FROM rust:1-slim-bookworm AS builder
5
 
6
- WORKDIR /app
 
 
 
 
 
7
 
 
8
  RUN apt-get update && apt-get install -y --no-install-recommends \
9
- pkg-config \
10
- libssl-dev \
11
- ca-certificates \
 
 
12
  && rm -rf /var/lib/apt/lists/*
13
 
14
- # Cache dependency builds using skeleton manifests
15
- COPY Cargo.toml ./
16
- RUN mkdir src && echo "fn main() {}" > src/main.rs
17
- RUN cargo build --release
18
- RUN rm -rf src
19
 
20
- # Copy real application source code and compile final binary
21
- COPY src ./src
22
- RUN touch src/main.rs && cargo build --release
23
 
24
- # ------------------------------------------------------------------------------
25
- # 2. Runtime Stage
26
- # ------------------------------------------------------------------------------
27
- FROM debian:bookworm-slim AS runtime
28
 
29
- RUN apt-get update && apt-get install -y --no-install-recommends \
30
- ca-certificates \
31
- libssl3 \
32
- curl \
33
- && rm -rf /var/lib/apt/lists/*
34
-
35
- # Non-root user setup (UID 1000 strictly required by Hugging Face Spaces)
36
- RUN useradd -m -u 1000 appuser
37
-
38
- # Prepare writable storage directory for Tantivy indices
39
- RUN mkdir -p /data/index && chown -R appuser:appuser /data
40
 
41
- WORKDIR /app
42
-
43
- # Copy compiled binary from builder
44
- COPY --from=builder /app/target/release/rust-mcp-search /usr/local/bin/rust-mcp-search
45
-
46
- ENV PORT=7860 \
47
- HOST=0.0.0.0 \
48
- MCP_TRANSPORT=http \
49
- DATA_DIR=/data/index \
50
- RUST_LOG=info
51
-
52
- # Switch to non-root user
53
- USER 1000
54
 
55
  EXPOSE 7860
56
 
57
- HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
58
- CMD curl -f http://localhost:${PORT}/health || exit 1
59
-
60
- ENTRYPOINT ["/usr/local/bin/rust-mcp-search"]
 
1
+ FROM python:3.11-slim
 
 
 
2
 
3
+ ENV DEBIAN_FRONTEND=noninteractive \
4
+ PYTHONUNBUFFERED=1 \
5
+ PORT=7860 \
6
+ HOME=/home/user \
7
+ PLAYWRIGHT_BROWSERS_PATH=/home/user/.cache/ms-playwright \
8
+ PATH="/home/user/.local/bin:${PATH}"
9
 
10
+ # Install all Linux libraries required by Chromium
11
  RUN apt-get update && apt-get install -y --no-install-recommends \
12
+ wget curl ca-certificates libglib2.0-0 libnss3 libnspr4 \
13
+ libatk1.0-0 libatk-bridge2.0-0 libcups2 libdrm2 libdbus-1-3 libxcb1 \
14
+ libxkbcommon0 libx11-6 libxcomposite1 libxdamage1 libxext6 libxfixes3 \
15
+ libxrandr2 libgbm1 libpango-1.0-0 libcairo2 libasound2 \
16
+ fonts-liberation fonts-noto-color-emoji \
17
  && rm -rf /var/lib/apt/lists/*
18
 
19
+ # Create non-root Hugging Face user (UID 1000)
20
+ RUN useradd -m -u 1000 user && \
21
+ mkdir -p /home/user/app /home/user/.cache/ms-playwright && \
22
+ chown -R user:user /home/user
 
23
 
24
+ WORKDIR /home/user/app
 
 
25
 
26
+ # Install Python requirements
27
+ COPY --chown=user:user requirements.txt .
28
+ RUN pip install --no-cache-dir -r requirements.txt
 
29
 
30
+ # Switch to user and download Patchright Chromium
31
+ USER user
32
+ RUN python -m patchright install chromium
 
 
 
 
 
 
 
 
33
 
34
+ COPY --chown=user:user . .
 
 
 
 
 
 
 
 
 
 
 
 
35
 
36
  EXPOSE 7860
37
 
38
+ CMD ["python", "app.py"]