mike23415 commited on
Commit
ae6b9c4
·
verified ·
1 Parent(s): 3696c1f

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +16 -10
Dockerfile CHANGED
@@ -7,24 +7,30 @@ WORKDIR /app
7
  # Install system dependencies for PyPDF2, python-pptx, etc.
8
  RUN apt-get update && apt-get install -y --no-install-recommends \
9
  gcc \
 
10
  && rm -rf /var/lib/apt/lists/*
11
 
12
- # Copy requirements file and install Python dependencies
13
- COPY requirements.txt .
14
- RUN pip install --no-cache-dir -r requirements.txt
 
 
15
 
16
- # Set a writable cache directory for Hugging Face models
17
- ENV HF_HOME=/app/hf_cache
18
- RUN mkdir -p /app/hf_cache && chmod -R 777 /app/hf_cache
19
 
20
- # Pre-download T5-Base model and tokenizer
21
- RUN python -c "from transformers import T5Tokenizer, T5ForConditionalGeneration; T5Tokenizer.from_pretrained('t5-base'); T5ForConditionalGeneration.from_pretrained('t5-base')"
 
22
 
23
  # Copy the entire application
24
- COPY . .
 
 
 
25
 
26
  # Expose the application port
27
  EXPOSE 7860
28
 
29
  # Run Gunicorn with logging
30
- CMD ["gunicorn", "-w", "2", "-b", "0.0.0.0:7860", "--log-level", "info", "app:app"]
 
7
  # Install system dependencies for PyPDF2, python-pptx, etc.
8
  RUN apt-get update && apt-get install -y --no-install-recommends \
9
  gcc \
10
+ python3-dev \
11
  && rm -rf /var/lib/apt/lists/*
12
 
13
+ # Copy requirements file
14
+ COPY requirements.txt .
15
+
16
+ # Add flask-cors to requirements if not already there
17
+ RUN grep -q "flask-cors" requirements.txt || echo "flask-cors" >> requirements.txt
18
 
19
+ # Install Python dependencies
20
+ RUN pip install --no-cache-dir -r requirements.txt
 
21
 
22
+ # Create a non-root user to run the application
23
+ RUN useradd -m appuser
24
+ RUN mkdir -p /app/uploads /app/temp && chown -R appuser:appuser /app
25
 
26
  # Copy the entire application
27
+ COPY --chown=appuser:appuser . .
28
+
29
+ # Switch to the non-root user
30
+ USER appuser
31
 
32
  # Expose the application port
33
  EXPOSE 7860
34
 
35
  # Run Gunicorn with logging
36
+ CMD ["gunicorn", "-w", "2", "-b", "0.0.0.0:7860", "--log-level", "info", "--timeout", "120", "app:app"]