-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
50 lines (37 loc) · 1.64 KB
/
Copy pathDockerfile
File metadata and controls
50 lines (37 loc) · 1.64 KB
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 pytorch/pytorch:2.2.0-cuda11.8-cudnn8-runtime
WORKDIR /app
# Install system deps - combine and clean in one layer
RUN apt-get update && apt-get install -y --no-install-recommends \
ffmpeg \
libgl1-mesa-glx \
libglib2.0-0 \
curl \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
# Copy requirements first for caching
COPY requirements.txt /app/requirements.txt
# Install Python deps
RUN pip install --upgrade pip
# Force NumPy 1.x before installing other deps to prevent NumPy 2.x
RUN pip install --no-cache-dir "numpy<2.0.0,>=1.23.0"
RUN pip install --no-cache-dir -r requirements.txt
# Copy the rest of the code (includes app.py, main.py, model file if small enough)
COPY . /app
# Ensure model file exists - copy it explicitly
COPY best_90-100_colab.pt /app/best_90-100_colab.pt
# Verify model file exists and show its size
RUN ls -lh /app/best_90-100_colab.pt && \
echo "Model file verified: $(du -h /app/best_90-100_colab.pt)"
# Gradio + uvicorn env
ENV GRADIO_SERVER_NAME=0.0.0.0
ENV GRADIO_SERVER_PORT=7860
ENV MODEL_PATH=/app/best_90-100_colab.pt
# Verify critical files exist before starting
RUN test -f /app/main.py || (echo "main.py missing!" && exit 1)
RUN test -f /app/app.py || (echo "app.py missing!" && exit 1)
RUN test -f /app/best_90-100_colab.pt || (echo "Model file missing!" && exit 1)
EXPOSE 7860
# Health check for local testing
HEALTHCHECK --interval=30s --timeout=10s --start-period=60s --retries=3 \
CMD curl -f http://localhost:7860/live || exit 1
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860", "--log-level", "info"]