WebashalarForML commited on
Commit
9e4a797
·
verified ·
1 Parent(s): 700d04b

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +42 -26
Dockerfile CHANGED
@@ -1,37 +1,53 @@
1
- FROM python:3.9-slim-bullseye
 
2
 
3
- # Disable Numba’s JIT cache (avoids Librosa/Numba caching errors)
4
- ENV NUMBA_DISABLE_JIT=1
5
-
6
- # Python & app environment
7
- ENV PYTHONUNBUFFERED=1 \
8
- PORT=7860
9
 
 
10
  WORKDIR /app
11
 
12
- # Install system dependencies
13
- RUN apt-get update && apt-get install -y --no-install-recommends \
14
- ffmpeg git curl \
15
- libgl1-mesa-glx libglib2.0-0 libsm6 libxrender1 libxext6 \
16
- build-essential \
17
- llvm llvm-dev clang-11 \
18
- && rm -rf /var/lib/apt/lists/*
 
 
 
 
 
 
 
19
 
20
- # Upgrade pip and pre‑install numpy
21
- RUN pip install --upgrade pip
22
- # && pip install numpy==1.21.6
23
 
24
- # Install Gunicorn + Python deps
25
- COPY requirements.txt .
26
- RUN pip install --no-cache-dir -r requirements.txt
27
 
28
- # Create directories
29
- RUN mkdir -p cache uploads results checkpoints temp \
30
- && chmod -R 777 cache uploads results checkpoints temp
31
 
32
- # Copy app code
33
- COPY . .
34
 
 
 
 
 
 
 
35
  EXPOSE 7860
36
 
37
- CMD ["gunicorn", "--bind", "0.0.0.0:7860", "app:app"]
 
 
 
 
 
 
1
+ # Use an official Python runtime as a parent image
2
+ FROM python:3.9-slim
3
 
4
+ # Set environment variables for Python
5
+ ENV PYTHONDONTWRITEBYTECODE=1 \
6
+ PYTHONUNBUFFERED=1
 
 
 
7
 
8
+ # Set the working directory
9
  WORKDIR /app
10
 
11
+ # Copy the requirements file into the container at /app
12
+ COPY requirements.txt /app/
13
+
14
+ # Install build dependencies for numba/llvmlite (LLVM) and then numpy
15
+ # This needs to be done before installing the rest of requirements.txt
16
+ RUN apt-get update && \
17
+ apt-get install -y --no-install-recommends \
18
+ llvm-11-dev \
19
+ libllvm11 \
20
+ clang && \
21
+ rm -rf /var/lib/apt/lists/*
22
+
23
+ # Install numpy first, as numba/llvmlite depend on it for building
24
+ RUN pip install --no-cache-dir numpy
25
 
26
+ # Install the rest of the dependencies and the SpaCy model in a single layer to optimize image size
27
+ RUN pip install --no-cache-dir -r requirements.txt && \
28
+ python -m spacy download en_core_web_sm
29
 
30
+ # Create necessary directories with appropriate permissions
31
+ RUN mkdir -p /tmp/flask_sessions /app/flask_sessions /app/uploads && \
32
+ chmod -R 777 /tmp/flask_sessions /app/flask_sessions /app/uploads
33
 
34
+ # Ensure all relevant directories have the correct permissions
35
+ RUN chmod -R 777 /app
 
36
 
37
+ # Copy the rest of the application code to /app
38
+ COPY . /app/
39
 
40
+ # Ensure the upload directory and app directory have the correct permissions
41
+ RUN mkdir -p /app/uploads && \
42
+ chmod -R 777 /app/uploads && \
43
+ chmod -R 777 /app
44
+
45
+ # Expose the port the app runs on
46
  EXPOSE 7860
47
 
48
+ # Set environment variables for Flask
49
+ ENV FLASK_APP=app.py \
50
+ FLASK_ENV=production
51
+
52
+ # Command to run the application
53
+ CMD ["gunicorn", "-w", "1", "-b", "0.0.0.0:7860", "--timeout", "120", "app:app"]