Spaces:
Running
Running
Update Dockerfile
Browse files- Dockerfile +21 -20
Dockerfile
CHANGED
@@ -1,36 +1,37 @@
|
|
1 |
-
FROM python:3.9
|
2 |
|
3 |
WORKDIR /app
|
4 |
|
5 |
# Install system dependencies
|
6 |
RUN apt-get update && apt-get install -y \
|
7 |
build-essential \
|
8 |
-
cmake \
|
9 |
python3-dev \
|
10 |
libeigen3-dev \
|
11 |
python3-pybind11 \
|
12 |
&& rm -rf /var/lib/apt/lists/*
|
13 |
|
14 |
-
#
|
15 |
-
|
16 |
-
|
17 |
-
# Copy all files at once to maintain relationships
|
18 |
-
COPY . .
|
19 |
-
|
20 |
-
# Install Python dependencies
|
21 |
RUN pip install --no-cache-dir -r requirements.txt
|
22 |
|
23 |
-
#
|
24 |
-
|
25 |
-
|
26 |
-
#
|
27 |
-
RUN
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
34 |
|
35 |
# Run the application
|
36 |
CMD ["streamlit", "run", "app.py"]
|
|
|
1 |
+
FROM python:3.9-slim
|
2 |
|
3 |
WORKDIR /app
|
4 |
|
5 |
# Install system dependencies
|
6 |
RUN apt-get update && apt-get install -y \
|
7 |
build-essential \
|
|
|
8 |
python3-dev \
|
9 |
libeigen3-dev \
|
10 |
python3-pybind11 \
|
11 |
&& rm -rf /var/lib/apt/lists/*
|
12 |
|
13 |
+
# Copy files
|
14 |
+
COPY requirements.txt .
|
|
|
|
|
|
|
|
|
|
|
15 |
RUN pip install --no-cache-dir -r requirements.txt
|
16 |
|
17 |
+
# Copy C++ source and app
|
18 |
+
COPY cubic_cpp.cpp app.py ./
|
19 |
+
|
20 |
+
# Get Python and pybind11 include paths directly
|
21 |
+
RUN PYTHON_INCLUDE_PATH=$(python3 -c "import sysconfig; print(sysconfig.get_path('include'))") && \
|
22 |
+
PYBIND11_INCLUDE_PATH=$(python3 -c "import pybind11; print(pybind11.get_include())") && \
|
23 |
+
NUMPY_INCLUDE_PATH=$(python3 -c "import numpy; print(numpy.get_include())") && \
|
24 |
+
# Compile the C++ module directly to a shared library
|
25 |
+
g++ -O3 -Wall -shared -std=c++11 -fPIC \
|
26 |
+
$(python3-config --includes) \
|
27 |
+
-I${PYBIND11_INCLUDE_PATH} \
|
28 |
+
-I${NUMPY_INCLUDE_PATH} \
|
29 |
+
cubic_cpp.cpp \
|
30 |
+
-o cubic_cpp$(python3-config --extension-suffix) && \
|
31 |
+
# Verify the module was created
|
32 |
+
ls -la && \
|
33 |
+
# Test the import
|
34 |
+
python3 -c "import cubic_cpp; print('C++ module imported successfully')"
|
35 |
|
36 |
# Run the application
|
37 |
CMD ["streamlit", "run", "app.py"]
|