Miakat commited on
Commit
e358e01
·
verified ·
1 Parent(s): fe46e3d

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +17 -17
Dockerfile CHANGED
@@ -2,30 +2,30 @@
2
  # read the doc: https://huggingface.co/docs/hub/spaces-sdks-docker
3
  # you will also find guides on how best to write your Dockerfile
4
 
5
- # Base image
6
  FROM python:3.9
7
 
8
- # Add a non-root user for better security
9
- RUN useradd -m -u 1000 user
10
-
11
- # Set working directory for the application
12
- WORKDIR /app
13
 
14
- # Copy requirements file
15
- COPY ./requirements.txt /app/requirements.txt
16
 
17
- # Install dependencies from requirements.txt
18
- RUN pip install --no-cache-dir --upgrade -r /app/requirements.txt
19
 
20
- # Switch to the non-root user
 
 
21
  USER user
22
-
23
- # Set environment variables
24
  ENV HOME=/home/user \
25
- PATH=/home/user/.local/bin:$PATH
 
 
 
26
 
27
- # Copy application code to the container
28
- COPY --chown=user . /app
29
 
30
- # Command to run the application
31
  CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]
 
2
  # read the doc: https://huggingface.co/docs/hub/spaces-sdks-docker
3
  # you will also find guides on how best to write your Dockerfile
4
 
5
+ # Use the official Python 3.9 image
6
  FROM python:3.9
7
 
8
+ # Set the working directory to /code
9
+ WORKDIR /code
 
 
 
10
 
11
+ # Copy the current directory contents into the container at /code
12
+ COPY ./requirements.txt /code/requirements.txt
13
 
14
+ # Install requirements.txt
15
+ RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt
16
 
17
+ # Set up a new user named "user" with user ID 1000
18
+ RUN useradd -m -u 1000 user
19
+ # Switch to the "user" user
20
  USER user
21
+ # Set home to the user's home directory
 
22
  ENV HOME=/home/user \
23
+ PATH=/home/user/.local/bin:$PATH
24
+
25
+ # Set the working directory to the user's home directory
26
+ WORKDIR $HOME/app
27
 
28
+ # Copy the current directory contents into the container at $HOME/app setting the owner to the user
29
+ COPY --chown=user . $HOME/app
30
 
 
31
  CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]