admin08077 commited on
Commit
69caade
·
verified ·
1 Parent(s): 39ba312

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +67 -28
Dockerfile CHANGED
@@ -1,58 +1,97 @@
1
- # Base Image
2
  FROM ubuntu:22.04
3
 
4
- # Non-interactive setup for APT
5
  ENV DEBIAN_FRONTEND=noninteractive
6
-
7
- # Python environment variables
8
  ENV PYTHONDONTWRITEBYTECODE=1
9
  ENV PYTHONUNBUFFERED=1
10
 
11
- # Install system dependencies and FEniCSx
12
  RUN apt-get update && apt-get install -y --no-install-recommends \
13
- software-properties-common \
14
  build-essential \
15
  cmake \
 
16
  git \
17
- ffmpeg \
18
- git-lfs \
19
  curl \
20
- nodejs \
21
  python3.10 \
22
  python3.10-venv \
23
  python3-pip \
24
- wget \
25
- && add-apt-repository ppa:fenics-packages/fenics -y \
26
- && apt-get update \
27
- && apt-get install -y fenicsx \
28
- && rm -rf /var/lib/apt/lists/*
 
 
 
 
29
 
30
- # Python virtual environment
 
 
 
 
 
 
31
  RUN python3.10 -m venv /opt/venv
32
- ENV PATH="/opt/venv/bin:$PATH"
33
 
34
- # Upgrade pip and install FEniCSx bindings
35
- RUN pip install --upgrade pip && pip install fenics-dolfinx mpi4py
 
36
 
37
- # Verify FEniCSx installation
38
- RUN python -c "import dolfinx; print('FEniCSx version:', dolfinx.__version__)"
 
 
 
39
 
40
- # Install Python dependencies
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
41
  COPY requirements.txt /tmp/requirements.txt
42
  RUN pip install --no-cache-dir -r /tmp/requirements.txt
43
- RUN pip install --no-cache-dir gradio[oauth]==5.9.1 "uvicorn>=0.14.0" spaces
44
 
45
- # Optional: Freeze installed packages
 
 
 
 
 
 
46
  RUN pip freeze > /tmp/freeze.txt
47
 
48
- # Set working directory
49
  WORKDIR /home/user/app
50
 
51
- # Copy application code
52
- COPY --chown=1000:1000 ./ /home/user/app
53
 
54
- # Expose application port
55
  EXPOSE 7860
56
 
57
- # Define the default command
58
  CMD ["python3.10", "app.py"]
 
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++ \
15
  git \
16
+ wget \
 
17
  curl \
18
+ pkg-config \
19
  python3.10 \
20
  python3.10-venv \
21
  python3-pip \
22
+ python3-dev \
23
+ libboost-all-dev \
24
+ libhdf5-dev \
25
+ libpugixml-dev \
26
+ libspdlog-dev \
27
+ libopenmpi-dev \
28
+ libparmetis-dev \
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"]