File size: 2,903 Bytes
976e75b
b68c6e2
494ee03
976e75b
494ee03
b68c6e2
 
 
976e75b
b68c6e2
976e75b
494ee03
b68c6e2
69caade
b68c6e2
69caade
b68c6e2
69caade
b68c6e2
 
 
69caade
 
 
 
 
 
 
 
 
494ee03
976e75b
69caade
 
 
 
 
976e75b
340f7fe
 
976e75b
 
 
 
69caade
976e75b
 
69caade
340f7fe
976e75b
69caade
 
 
 
494ee03
976e75b
69caade
 
 
 
 
976e75b
69caade
 
 
976e75b
 
69caade
 
 
976e75b
 
69caade
976e75b
69caade
 
976e75b
b68c6e2
340f7fe
976e75b
494ee03
976e75b
458a310
494ee03
976e75b
458a310
b68c6e2
976e75b
69caade
b68c6e2
976e75b
b68c6e2
494ee03
976e75b
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
# Use an official Ubuntu base image
FROM ubuntu:22.04

# Set non-interactive mode for apt
ENV DEBIAN_FRONTEND=noninteractive
ENV PYTHONDONTWRITEBYTECODE=1
ENV PYTHONUNBUFFERED=1

# Install system dependencies
RUN apt-get update && apt-get install -y --no-install-recommends \
    software-properties-common \
    build-essential \
    cmake \
    g++ \
    git \
    wget \
    curl \
    pkg-config \
    python3.10 \
    python3.10-venv \
    python3-pip \
    python3-dev \
    libboost-all-dev \
    libhdf5-dev \
    libpugixml-dev \
    libspdlog-dev \
    libopenmpi-dev \
    libparmetis-dev \
    libscotch-dev \
    && apt-get clean && rm -rf /var/lib/apt/lists/*

# Install PETSc dependencies
RUN apt-get update && apt-get install -y --no-install-recommends \
    libhypre-dev \
    libmumps-dev \
    && apt-get clean && rm -rf /var/lib/apt/lists/*

# Create Python virtual environment
RUN python3.10 -m venv /opt/venv

# Activate virtual environment
ENV PATH="/opt/venv/bin:$PATH"

# Upgrade pip and install Python packages
RUN pip install --upgrade pip

# Install mpi4py and additional Python packages
RUN pip install numpy mpi4py cffi scikit-build-core[pyproject] petsc4py slepc4py

# Clone and build Basix (required by dolfinx)
RUN git clone --branch main https://github.com/FEniCS/basix.git /tmp/basix && \
    mkdir -p /tmp/basix/build && cd /tmp/basix/build && \
    cmake -DCMAKE_INSTALL_PREFIX=/usr/local .. && \
    make -j$(nproc) && make install

# Clone and build UFCx (required by dolfinx)
RUN git clone --branch main https://github.com/FEniCS/ufcx.git /tmp/ufcx && \
    mkdir -p /tmp/ufcx/build && cd /tmp/ufcx/build && \
    cmake -DCMAKE_INSTALL_PREFIX=/usr/local .. && \
    make -j$(nproc) && make install

# Clone and build dolfinx (C++ core and Python bindings)
RUN git clone --branch main https://github.com/FEniCS/dolfinx.git /tmp/dolfinx && \
    mkdir -p /tmp/dolfinx/cpp/build && cd /tmp/dolfinx/cpp/build && \
    cmake -DCMAKE_INSTALL_PREFIX=/usr/local .. && \
    make -j$(nproc) && make install && \
    cd /tmp/dolfinx/python && \
    pip install -r build-requirements.txt && \
    pip install --check-build-dependencies --no-build-isolation .

# Verify dolfinx installation
RUN python -c "import dolfinx; print('dolfinx version:', dolfinx.__version__)"

# Clean up build files
RUN rm -rf /tmp/basix /tmp/ufcx /tmp/dolfinx

# Install Gradio and other Python dependencies
COPY requirements.txt /tmp/requirements.txt
RUN pip install --no-cache-dir -r /tmp/requirements.txt
RUN pip install --no-cache-dir gradio[oauth]==5.9.1 "uvicorn>=0.14.0" spaces matplotlib pandas

# Freeze installed Python packages (optional)
RUN pip freeze > /tmp/freeze.txt

# Set application working directory
WORKDIR /home/user/app

# Copy application files
COPY . /home/user/app

# Expose the Gradio app port
EXPOSE 7860

# Set default command to run the app
CMD ["python", "app.py"]