-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathDockerfile
66 lines (51 loc) · 1.53 KB
/
Dockerfile
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
# --------
# Builder stage
# --------
FROM python:3.11-slim AS builder
# Install build tools and dependencies
RUN apt-get update && apt-get install -y --no-install-recommends \
gcc \
g++ \
libc6-dev \
libffi-dev \
libpq-dev \
make \
&& rm -rf /var/lib/apt/lists/*
# Set working directory for builder
WORKDIR /app
# Copy the entire project first
COPY . /app/
# Upgrade pip and build wheels for all dependencies
RUN pip install --upgrade pip \
&& mkdir /wheels \
&& pip wheel --wheel-dir=/wheels -r requirements.txt
# --------
# Final runtime stage
# --------
FROM python:3.11-slim
# Install runtime dependencies
RUN apt-get update && apt-get install -y --no-install-recommends \
libffi-dev \
libpq-dev \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /app
# Copy the entire project
COPY . /app/
# Copy the wheels built in the builder stage
COPY --from=builder /wheels /wheels
# Install Python dependencies from the local wheel cache
RUN pip install --upgrade pip \
&& pip install --no-cache-dir --no-index --find-links=/wheels -r requirements.txt
# Create models directory
RUN mkdir -p /app/models
# Pre-download models
RUN python -c "from sentence_transformers import SentenceTransformer; \
model = SentenceTransformer('all-MiniLM-L6-v2'); \
model.save('/app/models/all-MiniLM-L6-v2')"
# Set environment variables
ENV SENTENCE_TRANSFORMERS_HOME=/app/models
ENV PYTHONPATH=/app/src
# Expose port
EXPOSE 8000
# Run the server directly
ENTRYPOINT ["python", "src/mcp_server_any_openapi/server.py"]