WebashalarForML commited on
Commit
c139d5e
·
verified ·
1 Parent(s): b91fe21

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +18 -23
Dockerfile CHANGED
@@ -1,42 +1,37 @@
1
- # Use an official Python runtime as a parent image
2
  FROM python:3.11-slim
3
 
4
- # Set environment variables for Python
5
  ENV PYTHONDONTWRITEBYTECODE=1 \
6
- PYTHONUNBUFFERED=1
 
 
 
7
 
8
- # Set environment variables for Hugging Face cache
9
- ENV TRANSFORMERS_CACHE=/app/cache \
10
- HF_HOME=/app/cache
11
-
12
- ENV MPLCONFIGDIR=/tmp
13
-
14
- # Set the working directory
15
  WORKDIR /app
16
 
17
- # Copy the requirements file into the container at /app
18
  COPY requirements.txt /app/
19
 
20
- # Install dependencies
21
- RUN pip install --no-cache-dir -r requirements.txt
22
 
23
- # Create and set permissions for the cache directory
24
- RUN mkdir -p /app/cache && \
25
- chmod -R 777 /app/cache
 
 
 
26
 
27
- # Ensure all relevant directories have the correct permissions
 
28
  RUN chmod -R 777 /app
29
 
30
- # Copy the rest of the application code to /app
31
  COPY . /app/
32
 
33
- # Set environment variables for Flask
34
  ENV FLASK_APP=app.py \
35
  FLASK_ENV=production
36
 
37
- # Expose the port the app runs on
38
  EXPOSE 7860
39
 
40
- # Command to run the application
41
- # Command to run the application with a very high timeout
42
- CMD ["gunicorn", "-w", "1", "-b", "0.0.0.0:7860", "--timeout", "120", "app:app"]
 
 
1
  FROM python:3.11-slim
2
 
3
+ # Environment variables
4
  ENV PYTHONDONTWRITEBYTECODE=1 \
5
+ PYTHONUNBUFFERED=1 \
6
+ TRANSFORMERS_CACHE=/app/cache \
7
+ HF_HOME=/app/cache \
8
+ MPLCONFIGDIR=/tmp
9
 
 
 
 
 
 
 
 
10
  WORKDIR /app
11
 
12
+ # Copy the requirements file
13
  COPY requirements.txt /app/
14
 
15
+ # Upgrade pip
16
+ RUN pip install --upgrade pip
17
 
18
+ # (Optional) Install any necessary system dependencies
19
+ RUN apt-get update && apt-get install -y gcc libjpeg-dev zlib1g-dev && \
20
+ rm -rf /var/lib/apt/lists/*
21
+
22
+ # Install dependencies
23
+ RUN pip install --no-cache-dir -r requirements.txt
24
 
25
+ # Create cache directory and set permissions
26
+ RUN mkdir -p /app/cache && chmod -R 777 /app/cache
27
  RUN chmod -R 777 /app
28
 
29
+ # Copy the application code
30
  COPY . /app/
31
 
 
32
  ENV FLASK_APP=app.py \
33
  FLASK_ENV=production
34
 
 
35
  EXPOSE 7860
36
 
37
+ CMD ["gunicorn", "-w", "1", "-b", "0.0.0.0:7860", "--timeout", "120", "app:app"]