Nishant Kumar commited on
Commit
69fa150
1 Parent(s): 9747cab

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +17 -21
Dockerfile CHANGED
@@ -1,30 +1,26 @@
1
- # Base image with Python 3.8 (adjust if needed)
2
  FROM python:3.9
3
 
4
- # Working directory within the container
5
- WORKDIR /app
6
-
7
- # Create a non-root user and set permissions
8
- RUN useradd -ms /bin/bash appuser
9
 
10
- # Copy requirements.txt file
11
- COPY requirements.txt .
12
 
13
- # Change ownership of the copied file to the non-root user
14
- RUN chown appuser:appuser requirements.txt
15
 
16
- # Install dependencies
17
- RUN pip install --no-cache-dir -r requirements.txt
18
 
19
- # Copy entire application codebase and change ownership
20
- COPY . .
21
- RUN chown -R appuser:appuser /app
22
 
23
- # Switch to the non-root user
24
- USER appuser
25
 
26
- # Expose port for the application
27
- EXPOSE 7860
28
 
29
- # Run the application with Gunicorn
30
- CMD ["gunicorn", "--bind", "0.0.0.0:7860", "wsgi:app"]
 
1
+ # Use Python 3.9 as the base image
2
  FROM python:3.9
3
 
4
+ # Create a user named 'user' with UID 1000 and create its home directory
5
+ RUN useradd -m -u 1000 user
 
 
 
6
 
7
+ # Switch to the 'user' user for subsequent commands
8
+ USER user
9
 
10
+ # Add user's local bin directory to the PATH environment variable
11
+ ENV PATH="/home/user/.local/bin:$PATH"
12
 
13
+ # Set the working directory inside the container
14
+ WORKDIR /app
15
 
16
+ # Copy requirements.txt from the host to the container
17
+ COPY --chown=user ./requirements.txt requirements.txt
 
18
 
19
+ # Install Python dependencies listed in requirements.txt
20
+ RUN pip install --no-cache-dir --upgrade -r requirements.txt
21
 
22
+ # Copy the rest of the application code from the host to the container
23
+ COPY --chown=user . /app
24
 
25
+ # Specify the command to run the application with Gunicorn
26
+ CMD ["gunicorn", "--bind", "0.0.0.0:7860", "app:app"]