WebashalarForML commited on
Commit
9d2373a
·
verified ·
1 Parent(s): 712a0f2

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +15 -20
Dockerfile CHANGED
@@ -2,8 +2,8 @@
2
  FROM python:3.9-slim
3
 
4
  # Set environment variables for Python
5
- ENV PYTHONDONTWRITEBYTECODE 1
6
- ENV PYTHONUNBUFFERED 1
7
 
8
  # Set the working directory
9
  WORKDIR /app
@@ -11,36 +11,31 @@ WORKDIR /app
11
  # Copy the requirements file into the container at /app
12
  COPY requirements.txt /app/
13
 
14
- # Install any needed packages specified in requirements.txt
15
- RUN pip install --no-cache-dir -r requirements.txt
 
16
 
17
- # Install SpaCy model directly in Dockerfile after installing SpaCy
18
- RUN python -m spacy download en_core_web_sm
19
-
20
- # Create the directory for session storage and set permissions
21
- RUN mkdir -p /tmp/flask_sessions && chmod 777 /tmp/flask_sessions
22
-
23
- # Create flask_sessions directory and set permissions
24
- RUN mkdir -p /app/flask_sessions /app/uploads && chmod -R 777 /app/flask_sessions /app/uploads
25
 
26
  # Create the app_error.log file and set write permissions
27
  RUN touch /app/app_error.log && chmod 777 /app/app_error.log
28
 
 
 
 
29
  # Copy the rest of the application code to /app
30
  COPY . /app/
31
 
32
- # Ensure the upload directory and app directory have the correct permissions
33
- RUN mkdir -p /app/uploads && \
34
- chmod -R 777 /app/uploads && \
35
- chmod -R 777 /app
36
-
37
- # Expose the port that the app runs on
38
  EXPOSE 7860
39
 
40
  # Set environment variables for Flask
41
- ENV FLASK_APP=app.py
42
- ENV FLASK_ENV=production
43
 
44
  # Command to run the application
45
  CMD ["gunicorn", "-w", "1", "-b", "0.0.0.0:7860", "--timeout", "120", "app:app"]
 
46
  #CMD ["gunicorn", "--workers=5", "--threads=2", "--bind=0.0.0.0:7860", "--timeout=120", "app:app"]
 
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
 
11
  # Copy the requirements file into the container at /app
12
  COPY requirements.txt /app/
13
 
14
+ # Install dependencies and the SpaCy model in a single layer to optimize image size
15
+ RUN pip install --no-cache-dir -r requirements.txt && \
16
+ python -m spacy download en_core_web_sm
17
 
18
+ # Create necessary directories with appropriate permissions
19
+ RUN mkdir -p /tmp/flask_sessions /app/flask_sessions /app/uploads && \
20
+ chmod -R 777 /tmp/flask_sessions /app/flask_sessions /app/uploads
 
 
 
 
 
21
 
22
  # Create the app_error.log file and set write permissions
23
  RUN touch /app/app_error.log && chmod 777 /app/app_error.log
24
 
25
+ # Ensure all relevant directories have the correct permissions
26
+ RUN chmod -R 777 /app
27
+
28
  # Copy the rest of the application code to /app
29
  COPY . /app/
30
 
31
+ # Expose the port the app runs on
 
 
 
 
 
32
  EXPOSE 7860
33
 
34
  # Set environment variables for Flask
35
+ ENV FLASK_APP=app.py \
36
+ FLASK_ENV=production
37
 
38
  # Command to run the application
39
  CMD ["gunicorn", "-w", "1", "-b", "0.0.0.0:7860", "--timeout", "120", "app:app"]
40
+
41
  #CMD ["gunicorn", "--workers=5", "--threads=2", "--bind=0.0.0.0:7860", "--timeout=120", "app:app"]