levanel commited on
Commit
3cb9d60
·
1 Parent(s): 402851b

Fix Dockerfile stages and dependencies

Browse files
Files changed (1) hide show
  1. Dockerfile +13 -5
Dockerfile CHANGED
@@ -1,4 +1,6 @@
1
- # Stage 1: Build your module
 
 
2
  FROM python:3.10-slim AS builder
3
 
4
  RUN apt-get update && apt-get install -y --no-install-recommends \
@@ -9,7 +11,9 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
9
  && rm -rf /var/lib/apt/lists/*
10
 
11
  WORKDIR /app
12
- RUN pip install --no-cache-dir gradio numpy pypdf transformers torch --extra-index-url https://download.pytorch.org/whl/cpu
 
 
13
 
14
  # Copy only what your engine needs
15
  COPY CMakeLists.txt ./
@@ -20,13 +24,15 @@ RUN mkdir build && cd build && \
20
  cmake -DCMAKE_BUILD_TYPE=Release .. && \
21
  make vecmini
22
 
23
- # Stage 2: Final Runtime Environment
 
 
24
  FROM python:3.10-slim
25
 
26
  RUN useradd -m -u 1000 user
27
  WORKDIR /home/user/app
28
 
29
- # Install runtime math dependencies
30
  RUN apt-get update && apt-get install -y --no-install-recommends \
31
  libopenblas0 \
32
  libomp-dev \
@@ -37,7 +43,9 @@ COPY --from=builder /app/build/vecmini*.so /home/user/app/
37
 
38
  # Copy your frontend code (app.py)
39
  COPY --chown=user . /home/user/app
40
- RUN pip install --no-cache-dir gradio numpy
 
 
41
 
42
  ENV PORT=7860
43
  EXPOSE 7860
 
1
+ # ==========================================
2
+ # STAGE 1: Build Environment (Temporary)
3
+ # ==========================================
4
  FROM python:3.10-slim AS builder
5
 
6
  RUN apt-get update && apt-get install -y --no-install-recommends \
 
11
  && rm -rf /var/lib/apt/lists/*
12
 
13
  WORKDIR /app
14
+
15
+ # The builder ONLY needs pybind11 to compile the C++ code!
16
+ RUN pip install --no-cache-dir pybind11
17
 
18
  # Copy only what your engine needs
19
  COPY CMakeLists.txt ./
 
24
  cmake -DCMAKE_BUILD_TYPE=Release .. && \
25
  make vecmini
26
 
27
+ # ==========================================
28
+ # STAGE 2: Final Runtime Environment (Your App)
29
+ # ==========================================
30
  FROM python:3.10-slim
31
 
32
  RUN useradd -m -u 1000 user
33
  WORKDIR /home/user/app
34
 
35
+ # Install runtime C++ math dependencies
36
  RUN apt-get update && apt-get install -y --no-install-recommends \
37
  libopenblas0 \
38
  libomp-dev \
 
43
 
44
  # Copy your frontend code (app.py)
45
  COPY --chown=user . /home/user/app
46
+
47
+ # IMPORTANT: This is where ALL the runtime Python packages go!
48
+ RUN pip install --no-cache-dir gradio numpy pypdf transformers torch --extra-index-url https://download.pytorch.org/whl/cpu
49
 
50
  ENV PORT=7860
51
  EXPOSE 7860