mike23415 commited on
Commit
a5beb14
·
verified ·
1 Parent(s): ffab90e

Update Dockerfile

Browse files
Files changed (1) hide show
  1. 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 && apt-get install -y \
 
7
  build-essential \
8
- git \
9
  && rm -rf /var/lib/apt/lists/*
10
 
11
- # Create cache directories with proper permissions
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 the rest of the application
24
  COPY . .
25
 
26
- # Set environment variables for non-interactive execution
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
- # Expose the port the app runs on
 
 
 
 
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"]