Spaces:
Sleeping
Sleeping
Update Dockerfile
Browse files- Dockerfile +29 -14
Dockerfile
CHANGED
@@ -1,28 +1,43 @@
|
|
|
|
1 |
FROM python:3.10-slim
|
2 |
|
|
|
3 |
WORKDIR /app
|
4 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
5 |
# Install system dependencies
|
6 |
RUN apt-get update && apt-get install -y \
|
7 |
build-essential \
|
|
|
|
|
|
|
|
|
|
|
|
|
8 |
git \
|
|
|
9 |
&& rm -rf /var/lib/apt/lists/*
|
10 |
|
11 |
-
#
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
# Copy the rest of the application
|
16 |
-
COPY . .
|
17 |
|
18 |
-
#
|
19 |
-
|
|
|
|
|
20 |
|
21 |
-
#
|
22 |
-
|
23 |
|
24 |
-
# Expose the port
|
25 |
-
EXPOSE
|
26 |
|
27 |
-
#
|
28 |
-
CMD
|
|
|
1 |
+
# Use a lightweight Python image
|
2 |
FROM python:3.10-slim
|
3 |
|
4 |
+
# Set working directory
|
5 |
WORKDIR /app
|
6 |
|
7 |
+
# Set environment variables for Hugging Face cache
|
8 |
+
ENV HF_HOME=/tmp/huggingface
|
9 |
+
ENV TRANSFORMERS_CACHE=/tmp/huggingface/transformers
|
10 |
+
ENV HF_DATASETS_CACHE=/tmp/huggingface/datasets
|
11 |
+
ENV PYTHONDONTWRITEBYTECODE=1
|
12 |
+
ENV PYTHONUNBUFFERED=1
|
13 |
+
|
14 |
# Install system dependencies
|
15 |
RUN apt-get update && apt-get install -y \
|
16 |
build-essential \
|
17 |
+
libgl1-mesa-glx \
|
18 |
+
libglib2.0-0 \
|
19 |
+
libsm6 \
|
20 |
+
libxext6 \
|
21 |
+
libxrender-dev \
|
22 |
+
wget \
|
23 |
git \
|
24 |
+
&& apt-get clean \
|
25 |
&& rm -rf /var/lib/apt/lists/*
|
26 |
|
27 |
+
# Create necessary directories with appropriate permissions
|
28 |
+
RUN mkdir -p /tmp/uploads /tmp/results /tmp/huggingface/transformers /tmp/huggingface/datasets \
|
29 |
+
&& chmod -R 755 /tmp/uploads /tmp/results /tmp/huggingface
|
|
|
|
|
|
|
30 |
|
31 |
+
# Copy requirements file and install dependencies
|
32 |
+
COPY requirements.txt .
|
33 |
+
RUN pip install --no-cache-dir -U pip && \
|
34 |
+
pip install --no-cache-dir -r requirements.txt
|
35 |
|
36 |
+
# Copy application code
|
37 |
+
COPY app.py .
|
38 |
|
39 |
+
# Expose the port the app runs on (standard for Hugging Face Spaces)
|
40 |
+
EXPOSE 7860
|
41 |
|
42 |
+
# Command to run the application
|
43 |
+
CMD ["python", "app.py"]
|