devusman commited on
Commit
bf0c9ea
·
verified ·
1 Parent(s): f18901a

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +12 -12
Dockerfile CHANGED
@@ -1,24 +1,24 @@
1
- FROM python:3.9-slim
2
 
3
- # Create a non-root user for security
4
  RUN useradd -m -u 1000 user
5
  USER user
6
 
7
- # Add pip user installs to PATH
8
  ENV PATH="/home/user/.local/bin:$PATH"
9
 
10
- # Set working directory
11
  WORKDIR /app
12
 
13
- # Copy and install dependencies
14
- COPY --chown=user requirements.txt .
 
15
  RUN pip install --no-cache-dir --upgrade -r requirements.txt
16
 
17
- # Copy rest of the code
18
  COPY --chown=user . /app
19
 
20
- # Expose port (optional, but good practice)
21
- EXPOSE 7860
22
-
23
- # Start Gunicorn server
24
- CMD ["gunicorn", "-b", "0.0.0.0:7860", "app:app"]
 
1
+ FROM python:3.9
2
 
3
+ # Create a non-root user for better security
4
  RUN useradd -m -u 1000 user
5
  USER user
6
 
7
+ # Add the user's local bin to the PATH. This is where pip installs executables.
8
  ENV PATH="/home/user/.local/bin:$PATH"
9
 
10
+ # Set the working directory inside the container
11
  WORKDIR /app
12
 
13
+ # Copy only the requirements.txt first to leverage Docker layer caching
14
+ COPY --chown=user ./requirements.txt requirements.txt
15
+ # Install the dependencies specified in requirements.txt
16
  RUN pip install --no-cache-dir --upgrade -r requirements.txt
17
 
18
+ # Copy the rest of your application code into the container
19
  COPY --chown=user . /app
20
 
21
+ # The CMD instruction tells Docker how to run your application.
22
+ # This command starts the Gunicorn server, binding it to port 7860 on all network interfaces,
23
+ # and points it to the 'app' object inside your 'app.py' file.
24
+ CMD ["gunicorn", "-b", "0.0.0.0:7860", "app:app"]