Spaces:
Running
Running
Update Dockerfile
Browse files- Dockerfile +4 -43
Dockerfile
CHANGED
@@ -1,57 +1,18 @@
|
|
1 |
FROM python:3.10-slim
|
2 |
|
3 |
-
|
4 |
-
ENV PYTHONPATH=/home/user/app:$PYTHONPATH
|
5 |
|
6 |
-
WORKDIR /home/user/app
|
7 |
-
|
8 |
-
# Install system dependencies
|
9 |
RUN apt-get update && apt-get install -y \
|
10 |
build-essential \
|
11 |
cmake \
|
12 |
-
python3-dev \
|
13 |
libeigen3-dev \
|
14 |
-
python3-pybind11 \
|
15 |
-
pkg-config \
|
16 |
&& rm -rf /var/lib/apt/lists/*
|
17 |
|
18 |
-
# Copy requirements and install Python dependencies
|
19 |
COPY requirements.txt .
|
20 |
RUN pip install --no-cache-dir -r requirements.txt
|
21 |
|
22 |
-
|
23 |
-
COPY cubic_cpp.cpp app.py ./
|
24 |
-
|
25 |
-
# Use a more robust compilation approach
|
26 |
-
RUN python3 -c "import numpy; import pybind11; import sys; print(f'Python executable: {sys.executable}, Python version: {sys.version}')" && \
|
27 |
-
EXT_SUFFIX=$(python3-config --extension-suffix) && \
|
28 |
-
echo "Extension suffix: ${EXT_SUFFIX}" && \
|
29 |
-
g++ -O3 -shared -std=c++11 -fPIC \
|
30 |
-
$(python3-config --includes) \
|
31 |
-
-I$(python3 -c "import pybind11; print(pybind11.get_include())") \
|
32 |
-
-I$(python3 -c "import numpy; print(numpy.get_include())") \
|
33 |
-
cubic_cpp.cpp \
|
34 |
-
-o cubic_cpp${EXT_SUFFIX} && \
|
35 |
-
# Copy to multiple possible locations
|
36 |
-
cp cubic_cpp${EXT_SUFFIX} /usr/local/lib/python3.10/site-packages/ && \
|
37 |
-
# List all created files
|
38 |
-
ls -la /home/user/app && \
|
39 |
-
ls -la /usr/local/lib/python3.10/site-packages/ | grep cubic && \
|
40 |
-
# Verify the module can be imported
|
41 |
-
python3 -c "import sys; print(sys.path); import cubic_cpp; print('Successfully imported cubic_cpp:', cubic_cpp.__file__)"
|
42 |
|
43 |
-
|
44 |
-
RUN sed -i '1s/^/import os, sys\n\
|
45 |
-
# Add current directory to path\n\
|
46 |
-
module_paths = [os.getcwd(), "\/home\/user\/app", "\/home\/user\/a"]\n\
|
47 |
-
for path in module_paths:\n\
|
48 |
-
if path not in sys.path:\n\
|
49 |
-
sys.path.insert(0, path)\n\
|
50 |
-
if os.path.exists(path):\n\
|
51 |
-
print(f"Path exists: {path}")\n\
|
52 |
-
files = [f for f in os.listdir(path) if "cubic_cpp" in f]\n\
|
53 |
-
if files:\n\
|
54 |
-
print(f"Found module files in {path}: {files}")\n\n/' app.py
|
55 |
|
56 |
-
|
57 |
-
CMD ["streamlit", "run", "app.py"]
|
|
|
1 |
FROM python:3.10-slim
|
2 |
|
3 |
+
WORKDIR /app
|
|
|
4 |
|
|
|
|
|
|
|
5 |
RUN apt-get update && apt-get install -y \
|
6 |
build-essential \
|
7 |
cmake \
|
|
|
8 |
libeigen3-dev \
|
|
|
|
|
9 |
&& rm -rf /var/lib/apt/lists/*
|
10 |
|
|
|
11 |
COPY requirements.txt .
|
12 |
RUN pip install --no-cache-dir -r requirements.txt
|
13 |
|
14 |
+
COPY app.py .
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
15 |
|
16 |
+
EXPOSE 8501
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
17 |
|
18 |
+
CMD ["streamlit", "run", "app.py", "--server.enableCORS=false", "--server.enableXsrfProtection=false"]
|
|