OmarAbualrob commited on
Commit
78905d5
·
verified ·
1 Parent(s): 79ed776

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +10 -17
Dockerfile CHANGED
@@ -3,35 +3,28 @@ FROM python:3.9-slim
3
 
4
  # Create a dedicated, non-root user for security.
5
  RUN useradd -m -u 1000 user
6
-
7
- # Switch to this new user.
8
  USER user
9
 
10
- # Set environment variables that will be available to the 'user'.
11
  ENV HOME=/home/user
12
-
13
- # --- THIS IS THE FIX ---
14
- # Add the user's local binary directory to the system's PATH.
15
- # This ensures that executables installed by pip (like uvicorn) can be found.
16
  ENV PATH=$HOME/.local/bin:$PATH
17
-
18
- # Set the cache directory for transformers.
19
  ENV TRANSFORMERS_CACHE=$HOME/.cache
20
-
21
- # Set the working directory for the application.
22
  WORKDIR $HOME/app
23
 
24
- # Copy and own the requirements file.
25
  COPY --chown=user:user ./requirements.txt .
26
 
27
- # Install Python dependencies.
 
 
 
 
 
28
  RUN pip install --no-cache-dir --upgrade -r requirements.txt
29
 
30
- # Copy and own the application file.
31
  COPY --chown=user:user ./app.py .
32
 
33
- # Expose the port the app will run on.
34
  EXPOSE 7860
35
-
36
- # Command to run your app. Now 'uvicorn' can be found in the PATH.
37
  CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]
 
3
 
4
  # Create a dedicated, non-root user for security.
5
  RUN useradd -m -u 1000 user
 
 
6
  USER user
7
 
8
+ # Set environment variables
9
  ENV HOME=/home/user
 
 
 
 
10
  ENV PATH=$HOME/.local/bin:$PATH
 
 
11
  ENV TRANSFORMERS_CACHE=$HOME/.cache
 
 
12
  WORKDIR $HOME/app
13
 
14
+ # Copy the requirements file
15
  COPY --chown=user:user ./requirements.txt .
16
 
17
+ # --- BUILD FIX ---
18
+ # 1. Upgrade pip itself and install the key build-time dependency first.
19
+ RUN pip install --no-cache-dir --upgrade pip setuptools
20
+ RUN pip install --no-cache-dir packaging
21
+
22
+ # 2. Now, install all the other requirements. pip will now find 'packaging'.
23
  RUN pip install --no-cache-dir --upgrade -r requirements.txt
24
 
25
+ # Copy the rest of the application
26
  COPY --chown=user:user ./app.py .
27
 
28
+ # Expose the port and run the application
29
  EXPOSE 7860
 
 
30
  CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]