File size: 1,469 Bytes
f7e81bd
 
c620ab3
f7e81bd
 
 
 
 
 
 
 
 
c620ab3
f7e81bd
c620ab3
f7e81bd
 
 
 
 
 
c620ab3
f7e81bd
c620ab3
f7e81bd
 
 
c620ab3
f7e81bd
 
 
 
c620ab3
f7e81bd
 
 
 
c620ab3
f7e81bd
 
c620ab3
 
 
 
f7e81bd
c620ab3
f7e81bd
c620ab3
 
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
FROM python:3.11-slim

# Basic env
ENV DEBIAN_FRONTEND=noninteractive \
    PYTHONUNBUFFERED=1 \
    PYTHONDONTWRITEBYTECODE=1 \
    HOME=/home/user \
    PATH=/home/user/.local/bin:$PATH \
    PYVISTA_OFF_SCREEN=true \
    DISPLAY=:99 \
    VTK_SILENCE_GET_VOID_POINTER_WARNINGS=1

# System deps for headless VTK/PyVista + Xvfb
RUN apt-get update && apt-get install -y --no-install-recommends \
    build-essential cmake wget xvfb \
    libosmesa6 libosmesa6-dev \
    libgl1 libgl1-mesa-dev \
    libegl1 libegl1-mesa-dev \
    libglu1-mesa libglu1-mesa-dev \
    libgles2-mesa-dev \
    libx11-6 libxt6 libxrender1 libsm6 libice6 \
  && rm -rf /var/lib/apt/lists/*

# Non-root user
RUN useradd -m -u 1000 user
WORKDIR /home/user/app

# Python deps (cached)
COPY requirements.txt .
RUN python3 -m pip install --upgrade pip setuptools wheel \
 && python3 -m pip install --no-cache-dir -r requirements.txt

# App code
COPY --chown=user:user . .

USER user

# HF expects service on $PORT (usually 7860)
EXPOSE 7860

# Optional: don’t override PORT; just ensure host is external
ENV APP_HOST=0.0.0.0

# Healthcheck on the expected port
HEALTHCHECK --interval=30s --timeout=10s --start-period=40s --retries=3 \
  CMD wget --no-verbose --tries=1 --spider http://127.0.0.1:${PORT:-7860}/ || exit 1

# Start Xvfb + run the app as PID1
CMD ["sh", "-c", "Xvfb :99 -screen 0 1024x768x24 >/dev/null 2>&1 & exec python3 app.py"]