admin08077 commited on
Commit
976e75b
·
verified ·
1 Parent(s): 64457a1

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +28 -30
Dockerfile CHANGED
@@ -1,14 +1,14 @@
1
- # Use an Ubuntu base image for compatibility with DOLFINx
2
  FROM ubuntu:22.04
3
 
4
- # Set environment variables for non-interactive installation
5
  ENV DEBIAN_FRONTEND=noninteractive
6
- ENV PATH="/opt/venv/bin:$PATH"
7
  ENV PYTHONDONTWRITEBYTECODE=1
8
  ENV PYTHONUNBUFFERED=1
9
 
10
- # Install basic system dependencies
11
  RUN apt-get update && apt-get install -y --no-install-recommends \
 
12
  build-essential \
13
  cmake \
14
  g++ \
@@ -29,69 +29,67 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
29
  libscotch-dev \
30
  && apt-get clean && rm -rf /var/lib/apt/lists/*
31
 
32
- # Install additional dependencies for PETSc and ParMETIS
33
  RUN apt-get update && apt-get install -y --no-install-recommends \
34
  libhypre-dev \
35
  libmumps-dev \
36
  && apt-get clean && rm -rf /var/lib/apt/lists/*
37
 
38
- # Create a Python virtual environment
39
  RUN python3.10 -m venv /opt/venv
40
 
41
- # Upgrade pip and install Python dependencies
 
 
 
42
  RUN pip install --upgrade pip
 
 
43
  RUN pip install numpy mpi4py cffi scikit-build-core[pyproject] petsc4py slepc4py
44
 
45
- # Clone and build Basix (required by DOLFINx)
46
  RUN git clone --branch main https://github.com/FEniCS/basix.git /tmp/basix && \
47
  mkdir -p /tmp/basix/build && cd /tmp/basix/build && \
48
  cmake -DCMAKE_INSTALL_PREFIX=/usr/local .. && \
49
  make -j$(nproc) && make install
50
 
51
- # Clone and build UFCx (required by DOLFINx)
52
  RUN git clone --branch main https://github.com/FEniCS/ufcx.git /tmp/ufcx && \
53
  mkdir -p /tmp/ufcx/build && cd /tmp/ufcx/build && \
54
  cmake -DCMAKE_INSTALL_PREFIX=/usr/local .. && \
55
  make -j$(nproc) && make install
56
 
57
- # Clone and build DOLFINx (C++ core)
58
  RUN git clone --branch main https://github.com/FEniCS/dolfinx.git /tmp/dolfinx && \
59
  mkdir -p /tmp/dolfinx/cpp/build && cd /tmp/dolfinx/cpp/build && \
60
  cmake -DCMAKE_INSTALL_PREFIX=/usr/local .. && \
61
- make -j$(nproc) && make install
62
-
63
- # Install DOLFINx Python interface
64
- RUN cd /tmp/dolfinx/python && \
65
  pip install -r build-requirements.txt && \
66
  pip install --check-build-dependencies --no-build-isolation .
67
 
68
- # Verify DOLFINx installation
69
- RUN python -c "import dolfinx; print('DOLFINx version:', dolfinx.__version__)"
70
 
71
- # Clean up build files to reduce image size
72
  RUN rm -rf /tmp/basix /tmp/ufcx /tmp/dolfinx
73
 
74
- # Copy requirements.txt and install additional Python packages
75
  COPY requirements.txt /tmp/requirements.txt
76
  RUN pip install --no-cache-dir -r /tmp/requirements.txt
 
77
 
78
- # Install Gradio and other app-related dependencies
79
- RUN pip install --no-cache-dir \
80
- gradio[oauth]==5.9.1 \
81
- "uvicorn>=0.14.0" \
82
- spaces
83
-
84
- # Freeze installed packages (optional)
85
  RUN pip freeze > /tmp/freeze.txt
86
 
87
- # Set the working directory for the application
88
  WORKDIR /home/user/app
89
 
90
- # Copy application code into the container
91
  COPY . /home/user/app
92
 
93
- # Expose the port for the application
94
  EXPOSE 7860
95
 
96
- # Define the default command to run the application
97
- CMD ["python3.10", "app.py"]
 
1
+ # Use an official Ubuntu base image
2
  FROM ubuntu:22.04
3
 
4
+ # Set non-interactive mode for apt
5
  ENV DEBIAN_FRONTEND=noninteractive
 
6
  ENV PYTHONDONTWRITEBYTECODE=1
7
  ENV PYTHONUNBUFFERED=1
8
 
9
+ # Install system dependencies
10
  RUN apt-get update && apt-get install -y --no-install-recommends \
11
+ software-properties-common \
12
  build-essential \
13
  cmake \
14
  g++ \
 
29
  libscotch-dev \
30
  && apt-get clean && rm -rf /var/lib/apt/lists/*
31
 
32
+ # Install PETSc dependencies
33
  RUN apt-get update && apt-get install -y --no-install-recommends \
34
  libhypre-dev \
35
  libmumps-dev \
36
  && apt-get clean && rm -rf /var/lib/apt/lists/*
37
 
38
+ # Create Python virtual environment
39
  RUN python3.10 -m venv /opt/venv
40
 
41
+ # Activate virtual environment
42
+ ENV PATH="/opt/venv/bin:$PATH"
43
+
44
+ # Upgrade pip and install Python packages
45
  RUN pip install --upgrade pip
46
+
47
+ # Install mpi4py and additional Python packages
48
  RUN pip install numpy mpi4py cffi scikit-build-core[pyproject] petsc4py slepc4py
49
 
50
+ # Clone and build Basix (required by dolfinx)
51
  RUN git clone --branch main https://github.com/FEniCS/basix.git /tmp/basix && \
52
  mkdir -p /tmp/basix/build && cd /tmp/basix/build && \
53
  cmake -DCMAKE_INSTALL_PREFIX=/usr/local .. && \
54
  make -j$(nproc) && make install
55
 
56
+ # Clone and build UFCx (required by dolfinx)
57
  RUN git clone --branch main https://github.com/FEniCS/ufcx.git /tmp/ufcx && \
58
  mkdir -p /tmp/ufcx/build && cd /tmp/ufcx/build && \
59
  cmake -DCMAKE_INSTALL_PREFIX=/usr/local .. && \
60
  make -j$(nproc) && make install
61
 
62
+ # Clone and build dolfinx (C++ core and Python bindings)
63
  RUN git clone --branch main https://github.com/FEniCS/dolfinx.git /tmp/dolfinx && \
64
  mkdir -p /tmp/dolfinx/cpp/build && cd /tmp/dolfinx/cpp/build && \
65
  cmake -DCMAKE_INSTALL_PREFIX=/usr/local .. && \
66
+ make -j$(nproc) && make install && \
67
+ cd /tmp/dolfinx/python && \
 
 
68
  pip install -r build-requirements.txt && \
69
  pip install --check-build-dependencies --no-build-isolation .
70
 
71
+ # Verify dolfinx installation
72
+ RUN python -c "import dolfinx; print('dolfinx version:', dolfinx.__version__)"
73
 
74
+ # Clean up build files
75
  RUN rm -rf /tmp/basix /tmp/ufcx /tmp/dolfinx
76
 
77
+ # Install Gradio and other Python dependencies
78
  COPY requirements.txt /tmp/requirements.txt
79
  RUN pip install --no-cache-dir -r /tmp/requirements.txt
80
+ RUN pip install --no-cache-dir gradio[oauth]==5.9.1 "uvicorn>=0.14.0" spaces matplotlib pandas
81
 
82
+ # Freeze installed Python packages (optional)
 
 
 
 
 
 
83
  RUN pip freeze > /tmp/freeze.txt
84
 
85
+ # Set application working directory
86
  WORKDIR /home/user/app
87
 
88
+ # Copy application files
89
  COPY . /home/user/app
90
 
91
+ # Expose the Gradio app port
92
  EXPOSE 7860
93
 
94
+ # Set default command to run the app
95
+ CMD ["python", "app.py"]