Update Dockerfile
Browse files- Dockerfile +11 -21
Dockerfile
CHANGED
@@ -3,38 +3,28 @@ FROM python:3.10-slim
|
|
3 |
WORKDIR /app
|
4 |
|
5 |
# Install system dependencies
|
6 |
-
RUN apt-get update &&
|
|
|
7 |
build-essential \
|
8 |
-
|
9 |
&& rm -rf /var/lib/apt/lists/*
|
10 |
|
11 |
-
#
|
12 |
-
RUN mkdir -p /cache /config && chmod 777 /cache /config
|
13 |
-
|
14 |
-
# Set environment variables to use the writable directories
|
15 |
-
ENV TRANSFORMERS_CACHE=/cache/huggingface
|
16 |
-
ENV HF_HOME=/cache/huggingface
|
17 |
-
ENV MPLCONFIGDIR=/config/matplotlib
|
18 |
-
|
19 |
-
# Copy requirements first for better caching
|
20 |
COPY requirements.txt .
|
21 |
RUN pip install --no-cache-dir -r requirements.txt
|
22 |
|
23 |
-
# Copy
|
24 |
COPY . .
|
25 |
|
26 |
-
# Set environment variables
|
27 |
ENV PYTHONUNBUFFERED=1
|
28 |
-
ENV TRANSFORMERS_NO_ADVISORY_WARNINGS=1
|
29 |
-
ENV HF_HUB_DISABLE_PROGRESS_BARS=1
|
30 |
-
ENV HF_HUB_DISABLE_TELEMETRY=1
|
31 |
-
# Add environment variable to enable wider GPU memory compatibility
|
32 |
-
ENV PYTORCH_CUDA_ALLOC_CONF=max_split_size_mb:128
|
33 |
|
34 |
-
#
|
|
|
|
|
|
|
|
|
35 |
EXPOSE 7860
|
36 |
-
# Also expose the Flask API port
|
37 |
-
EXPOSE 5000
|
38 |
|
39 |
# Command to run the application
|
40 |
CMD ["python", "app.py"]
|
|
|
3 |
WORKDIR /app
|
4 |
|
5 |
# Install system dependencies
|
6 |
+
RUN apt-get update && \
|
7 |
+
apt-get install -y --no-install-recommends \
|
8 |
build-essential \
|
9 |
+
&& apt-get clean \
|
10 |
&& rm -rf /var/lib/apt/lists/*
|
11 |
|
12 |
+
# Copy requirements and install dependencies
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
13 |
COPY requirements.txt .
|
14 |
RUN pip install --no-cache-dir -r requirements.txt
|
15 |
|
16 |
+
# Copy application code
|
17 |
COPY . .
|
18 |
|
19 |
+
# Set environment variables
|
20 |
ENV PYTHONUNBUFFERED=1
|
|
|
|
|
|
|
|
|
|
|
21 |
|
22 |
+
# Create cache directory with proper permissions
|
23 |
+
RUN mkdir -p /root/.cache/huggingface && \
|
24 |
+
chmod -R 777 /root/.cache/huggingface
|
25 |
+
|
26 |
+
# Expose port for the service
|
27 |
EXPOSE 7860
|
|
|
|
|
28 |
|
29 |
# Command to run the application
|
30 |
CMD ["python", "app.py"]
|