WebashalarForML commited on
Commit
eed6dfe
1 Parent(s): ff9c3da

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +24 -32
Dockerfile CHANGED
@@ -1,41 +1,33 @@
1
- # Use NVIDIA's CUDA base image with Python
2
- FROM nvidia/cuda:11.8.0-runtime-ubuntu20.04
3
 
4
- # Set environment variables
5
- ENV LANG=C.UTF-8 LC_ALL=C.UTF-8
6
- ENV PATH="/home/user/.local/bin:$PATH"
7
 
8
- # Install Python, pip, and other dependencies
9
- RUN apt-get update && apt-get install -y \
10
- python3 \
11
- python3-pip \
12
- python3-dev \
13
- libgl1-mesa-glx \
14
- libglib2.0-0 \ # Required for GLib
15
- && apt-get clean && rm -rf /var/lib/apt/lists/*
16
-
17
- # Create a non-root user
18
- RUN useradd -m user
19
-
20
- # Set the user to the non-root user
21
- USER user
22
-
23
- # Set the working directory to /app
24
  WORKDIR /app
25
 
26
- # Copy the requirements.txt file and install dependencies
27
- COPY --chown=user requirements.txt /app/requirements.txt
28
- RUN pip3 install --no-cache-dir --upgrade -r /app/requirements.txt
29
 
30
- # Copy the application code into the container
31
- COPY --chown=user . /app
32
 
33
- # Create the folders for uploads and results with appropriate permissions
34
- RUN mkdir -p /app/static/uploads /app/static/results && \
35
- chmod -R 755 /app/static/uploads /app/static/results
36
 
37
- # Expose the port the app will run on
 
 
 
38
  EXPOSE 7860
39
 
40
- # Run the Flask app using uvicorn
41
- CMD ["python3", "-m", "uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]
 
 
 
 
 
 
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
+ ENV PYTHONUNBUFFERED 1
7
 
8
+ # Set the working directory inside the container
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9
  WORKDIR /app
10
 
11
+ # Copy the requirements file into the container at /app
12
+ COPY requirements.txt /app/
 
13
 
14
+ # Install the dependencies specified in requirements.txt
15
+ RUN pip install --no-cache-dir -r requirements.txt
16
 
17
+ # Create the necessary directories and ensure they have proper permissions
18
+ RUN mkdir -p /app/uploads /app/static/uploads /app/static/results /tmp/flask_sessions /app/flask_sessions && \
19
+ chmod -R 777 /app/uploads /app/static/uploads /app/static/results /tmp/flask_sessions /app/flask_sessions
20
 
21
+ # Copy the entire application code to /app
22
+ COPY . /app/
23
+
24
+ # Expose the port used by the Flask app
25
  EXPOSE 7860
26
 
27
+ # Set environment variables for Flask
28
+ ENV FLASK_APP=app.py
29
+ ENV FLASK_ENV=production
30
+ ENV SESSION_FILE_DIR=/app/flask_sessions
31
+
32
+ # Run the application with Gunicorn, setting workers and timeout
33
+ CMD ["gunicorn", "-w", "1", "-b", "0.0.0.0:7860", "--timeout", "120", "app:app"]