Spaces:
Running
Running
Update Dockerfile
Browse files- Dockerfile +7 -15
Dockerfile
CHANGED
@@ -6,32 +6,24 @@ WORKDIR /app
|
|
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
|
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 |
-
#
|
21 |
-
RUN
|
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$
|
28 |
-
-I$
|
29 |
cubic_cpp.cpp \
|
30 |
-o cubic_cpp$(python3-config --extension-suffix) && \
|
31 |
-
#
|
32 |
-
|
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"]
|
|
|
6 |
RUN apt-get update && apt-get install -y \
|
7 |
build-essential \
|
8 |
python3-dev \
|
|
|
|
|
9 |
&& rm -rf /var/lib/apt/lists/*
|
10 |
|
11 |
+
# Copy requirements and install Python dependencies
|
12 |
COPY requirements.txt .
|
13 |
RUN pip install --no-cache-dir -r requirements.txt
|
14 |
|
15 |
# Copy C++ source and app
|
16 |
COPY cubic_cpp.cpp app.py ./
|
17 |
|
18 |
+
# Compile the C++ module directly with optimizations
|
19 |
+
RUN g++ -O3 -march=native -flto -ffast-math -Wall -shared -std=c++11 -fPIC \
|
|
|
|
|
|
|
|
|
20 |
$(python3-config --includes) \
|
21 |
+
-I$(python3 -c "import pybind11; print(pybind11.get_include())") \
|
22 |
+
-I$(python3 -c "import numpy; print(numpy.get_include())") \
|
23 |
cubic_cpp.cpp \
|
24 |
-o cubic_cpp$(python3-config --extension-suffix) && \
|
25 |
+
# Test the import
|
26 |
+
python3 -c "import cubic_cpp; print('C++ module successfully compiled and imported')"
|
|
|
|
|
27 |
|
28 |
# Run the application
|
29 |
CMD ["streamlit", "run", "app.py"]
|