File size: 1,493 Bytes
3cb9d60
 
 
e87a50a
 
 
 
 
 
 
 
 
 
3cb9d60
 
 
e87a50a
 
 
f4bbcb0
e87a50a
 
 
 
 
 
3cb9d60
 
 
e87a50a
 
 
 
 
3cb9d60
e87a50a
 
 
 
 
 
 
 
 
 
3cb9d60
 
e87a50a
f4bbcb0
e87a50a
 
 
 
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
# ==========================================
# STAGE 1: Build Environment (Temporary)
# ==========================================
FROM python:3.10-slim AS builder

RUN apt-get update && apt-get install -y --no-install-recommends \
    build-essential \
    cmake \
    libopenblas-dev \
    liblapack-dev \
    && rm -rf /var/lib/apt/lists/*

WORKDIR /app

# The builder ONLY needs pybind11 to compile the C++ code!
RUN pip install --no-cache-dir pybind11

# Copy only what your engine needs
COPY CMakeLists.txt ./
COPY src/ ./src	
COPY include/ ./include

RUN mkdir build && cd build && \
    cmake -DCMAKE_BUILD_TYPE=Release .. && \
    make vecmini

# ==========================================
# STAGE 2: Final Runtime Environment (Your App)
# ==========================================
FROM python:3.10-slim

RUN useradd -m -u 1000 user
WORKDIR /home/user/app

# Install runtime C++ math dependencies
RUN apt-get update && apt-get install -y --no-install-recommends \
    libopenblas0 \
    libomp-dev \
    && rm -rf /var/lib/apt/lists/*

# Copy the compiled .so module directly into the Python environment
COPY --from=builder /app/build/vecmini*.so /home/user/app/

# Copy your frontend code (app.py)
COPY --chown=user . /home/user/app

# IMPORTANT: This is where ALL the runtime Python packages go!

RUN pip install --no-cache-dir gradio numpy pypdf transformers torch urllib3 --extra-index-url https://download.pytorch.org/whl/cpu
ENV PORT=7860
EXPOSE 7860

CMD ["python", "app.py"]