sksameermujahid commited on
Commit
e3b515c
·
verified ·
1 Parent(s): f46b835

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +7 -45
Dockerfile CHANGED
@@ -5,61 +5,23 @@ WORKDIR /app
5
  # Install system dependencies
6
  RUN apt-get update && apt-get install -y \
7
  build-essential \
8
- libmagic1 \
 
9
  && rm -rf /var/lib/apt/lists/*
10
 
11
- # Create necessary directories with proper permissions
12
- RUN mkdir -p /app/static/uploads \
13
- && mkdir -p /app/logs \
14
- && mkdir -p /.cache/huggingface/hub \
15
- && mkdir -p /.cache/torch \
16
- && chmod -R 777 /app/logs \
17
- && chmod -R 777 /.cache/huggingface/hub \
18
- && chmod -R 777 /.cache/torch
19
-
20
  # Copy requirements first to leverage Docker cache
21
  COPY requirements.txt .
22
  RUN pip install --no-cache-dir -r requirements.txt
23
 
24
- # Install spaCy model
25
- RUN python -m spacy download en_core_web_md
26
-
27
- # Create models directory
28
- RUN mkdir -p /app/models
29
-
30
- # Copy application code
31
  COPY . .
32
 
33
  # Set environment variables
34
  ENV FLASK_APP=app.py
35
  ENV FLASK_ENV=production
36
- ENV TRANSFORMERS_CACHE=/.cache/huggingface/hub
37
- ENV TORCH_HOME=/.cache/torch
38
- ENV PYTHONUNBUFFERED=1
39
- ENV MODEL_DIR=/app/models
40
- ENV GUNICORN_CMD_ARGS="--access-logfile - --error-logfile - --log-level debug --timeout 300 --workers 1 --threads 4 --worker-class gthread --preload"
41
-
42
- # Create a startup script
43
- RUN echo '#!/bin/bash\n\
44
- echo "Starting application..."\n\
45
- echo "Checking model files..."\n\
46
- ls -la /app/models\n\
47
- echo "Starting Gunicorn..."\n\
48
- exec gunicorn --bind 0.0.0.0:8000 \
49
- --timeout 300 \
50
- --workers 1 \
51
- --threads 4 \
52
- --worker-class gthread \
53
- --preload \
54
- --access-logfile - \
55
- --error-logfile - \
56
- --log-level debug \
57
- --capture-output \
58
- --enable-stdio-inheritance \
59
- app:app' > /app/start.sh && chmod +x /app/start.sh
60
 
61
- # Expose port
62
- EXPOSE 8000
63
 
64
- # Run the startup script
65
- CMD ["/app/start.sh"]
 
5
  # Install system dependencies
6
  RUN apt-get update && apt-get install -y \
7
  build-essential \
8
+ libgl1-mesa-glx \
9
+ libglib2.0-0 \
10
  && rm -rf /var/lib/apt/lists/*
11
 
 
 
 
 
 
 
 
 
 
12
  # Copy requirements first to leverage Docker cache
13
  COPY requirements.txt .
14
  RUN pip install --no-cache-dir -r requirements.txt
15
 
16
+ # Copy the rest of the application
 
 
 
 
 
 
17
  COPY . .
18
 
19
  # Set environment variables
20
  ENV FLASK_APP=app.py
21
  ENV FLASK_ENV=production
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
22
 
23
+ # Expose the port
24
+ EXPOSE 7860
25
 
26
+ # Run the application
27
+ CMD ["python", "app.py"]