euler314 commited on
Commit
5fb933a
·
verified ·
1 Parent(s): 2afe8f0

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +9 -10
Dockerfile CHANGED
@@ -1,8 +1,8 @@
1
- FROM python:3.9-slim
2
 
3
- WORKDIR /app
4
 
5
- # Install system dependencies (all from your packages.txt)
6
  RUN apt-get update && apt-get install -y \
7
  build-essential \
8
  cmake \
@@ -12,22 +12,21 @@ RUN apt-get update && apt-get install -y \
12
  pkg-config \
13
  && rm -rf /var/lib/apt/lists/*
14
 
15
- # Copy all necessary files
16
  COPY requirements.txt .
17
- COPY cubic_cpp.cpp .
18
- COPY app.py .
19
-
20
- # Install Python dependencies
21
  RUN pip install --no-cache-dir -r requirements.txt
22
 
23
- # Compile the C++ module with more robust error handling
 
 
 
24
  RUN g++ -O3 -shared -std=c++11 -fPIC \
25
  $(python3-config --includes) \
26
  -I$(python3 -c "import pybind11; print(pybind11.get_include())") \
27
  -I$(python3 -c "import numpy; print(numpy.get_include())") \
28
  cubic_cpp.cpp \
29
  -o cubic_cpp$(python3-config --extension-suffix) && \
30
- # Test the import
31
  python3 -c "import cubic_cpp; print('C++ module successfully compiled and imported')"
32
 
33
  # Run the application
 
1
+ FROM python:3.10-slim
2
 
3
+ WORKDIR /home/user/app
4
 
5
+ # Install system dependencies
6
  RUN apt-get update && apt-get install -y \
7
  build-essential \
8
  cmake \
 
12
  pkg-config \
13
  && rm -rf /var/lib/apt/lists/*
14
 
15
+ # Copy requirements and install Python dependencies
16
  COPY requirements.txt .
 
 
 
 
17
  RUN pip install --no-cache-dir -r requirements.txt
18
 
19
+ # Copy C++ source and app
20
+ COPY cubic_cpp.cpp app.py ./
21
+
22
+ # Compile the C++ module and handle errors
23
  RUN g++ -O3 -shared -std=c++11 -fPIC \
24
  $(python3-config --includes) \
25
  -I$(python3 -c "import pybind11; print(pybind11.get_include())") \
26
  -I$(python3 -c "import numpy; print(numpy.get_include())") \
27
  cubic_cpp.cpp \
28
  -o cubic_cpp$(python3-config --extension-suffix) && \
29
+ ln -sf $(pwd)/cubic_cpp$(python3-config --extension-suffix) /usr/local/lib/python3.10/site-packages/ && \
30
  python3 -c "import cubic_cpp; print('C++ module successfully compiled and imported')"
31
 
32
  # Run the application