benkada commited on
Commit
df8f22b
·
verified ·
1 Parent(s): 4896d2f

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +16 -3
Dockerfile CHANGED
@@ -1,16 +1,29 @@
 
1
  FROM python:3.10
2
 
 
3
  WORKDIR /code
4
- COPY ./requirement.txt /code/requirement.txt
5
- RUN pip install --no-cache-dir --upgrade -r /code/requirement.txt
6
 
7
- RUN useradd user
 
 
 
 
 
8
  USER user
9
 
 
10
  ENV HOME=/home/user \
11
  PATH=/home/user/.local/bin:$PATH
12
 
 
13
  WORKDIR $HOME/app
 
 
14
  COPY --chown=user . $HOME/app
15
 
 
 
 
 
16
  CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]
 
1
+ # Use an official Python image
2
  FROM python:3.10
3
 
4
+ # Set work directory
5
  WORKDIR /code
 
 
6
 
7
+ # Copy and install dependencies
8
+ COPY ./requirements.txt /code/requirements.txt
9
+ RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt
10
+
11
+ # Create a non-root user and switch to it
12
+ RUN useradd -m user
13
  USER user
14
 
15
+ # Set environment variables
16
  ENV HOME=/home/user \
17
  PATH=/home/user/.local/bin:$PATH
18
 
19
+ # Work inside the user directory
20
  WORKDIR $HOME/app
21
+
22
+ # Copy the rest of the application code
23
  COPY --chown=user . $HOME/app
24
 
25
+ # Expose the port
26
+ EXPOSE 7860
27
+
28
+ # Run the app
29
  CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]