Spaces:
Runtime error
Runtime error
Update Dockerfile
Browse files- Dockerfile +52 -49
Dockerfile
CHANGED
@@ -1,49 +1,52 @@
|
|
1 |
-
# Use official Python image
|
2 |
-
FROM python:3.10-slim
|
3 |
-
|
4 |
-
# Disable interactive prompts
|
5 |
-
ENV DEBIAN_FRONTEND=noninteractive
|
6 |
-
|
7 |
-
# Set working directory
|
8 |
-
WORKDIR /app
|
9 |
-
|
10 |
-
# Install system dependencies
|
11 |
-
RUN apt-get update && apt-get install -y \
|
12 |
-
ffmpeg \
|
13 |
-
libsm6 \
|
14 |
-
libxext6 \
|
15 |
-
git \
|
16 |
-
curl \
|
17 |
-
&& rm -rf /var/lib/apt/lists/*
|
18 |
-
|
19 |
-
# Copy requirements and install Python packages
|
20 |
-
COPY requirements.txt .
|
21 |
-
|
22 |
-
# Upgrade pip first and set timeout + retries
|
23 |
-
RUN pip install --upgrade pip \
|
24 |
-
&& pip config set global.timeout 100 \
|
25 |
-
&& pip config set global.retries 10 \
|
26 |
-
&& pip install --no-cache-dir -r requirements.txt
|
27 |
-
|
28 |
-
RUN
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
ENV
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
#
|
46 |
-
|
47 |
-
|
48 |
-
#
|
49 |
-
|
|
|
|
|
|
|
|
1 |
+
# Use official Python image
|
2 |
+
FROM python:3.10-slim
|
3 |
+
|
4 |
+
# Disable interactive prompts
|
5 |
+
ENV DEBIAN_FRONTEND=noninteractive
|
6 |
+
|
7 |
+
# Set working directory
|
8 |
+
WORKDIR /app
|
9 |
+
|
10 |
+
# Install system dependencies
|
11 |
+
RUN apt-get update && apt-get install -y \
|
12 |
+
ffmpeg \
|
13 |
+
libsm6 \
|
14 |
+
libxext6 \
|
15 |
+
git \
|
16 |
+
curl \
|
17 |
+
&& rm -rf /var/lib/apt/lists/*
|
18 |
+
|
19 |
+
# Copy requirements and install Python packages
|
20 |
+
COPY requirements.txt .
|
21 |
+
|
22 |
+
# Upgrade pip first and set timeout + retries
|
23 |
+
RUN pip install --upgrade pip \
|
24 |
+
&& pip config set global.timeout 100 \
|
25 |
+
&& pip config set global.retries 10 \
|
26 |
+
&& pip install --no-cache-dir -r requirements.txt
|
27 |
+
|
28 |
+
RUN mkdir -p /app/static/uploads /app/static/outputs
|
29 |
+
|
30 |
+
RUN pip install --no-cache-dir -r requirements.txt
|
31 |
+
|
32 |
+
|
33 |
+
# Set Hugging Face cache directory
|
34 |
+
ENV HF_HOME=/models
|
35 |
+
ENV TRANSFORMERS_CACHE=/models/transformers
|
36 |
+
ENV HF_DATASETS_CACHE=/models/datasets
|
37 |
+
ENV HF_METRICS_CACHE=/models/metrics
|
38 |
+
|
39 |
+
# Pre-download the SAM model from Hugging Face
|
40 |
+
RUN python -c "\
|
41 |
+
from transformers import SamModel, SamProcessor; \
|
42 |
+
SamModel.from_pretrained('Zigeng/SlimSAM-uniform-50'); \
|
43 |
+
SamProcessor.from_pretrained('Zigeng/SlimSAM-uniform-50')"
|
44 |
+
|
45 |
+
# Copy all project files
|
46 |
+
COPY . .
|
47 |
+
|
48 |
+
# Expose port for Flask
|
49 |
+
EXPOSE 6000
|
50 |
+
|
51 |
+
# Run using gunicorn
|
52 |
+
CMD ["gunicorn", "--bind", "0.0.0.0:6000", "app:app"]
|