wesslen commited on
Commit
957af7c
·
1 Parent(s): e0092f3

update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +18 -10
Dockerfile CHANGED
@@ -2,22 +2,30 @@
2
  FROM python:3.9
3
 
4
  # Set the working directory in the container
5
- WORKDIR /app
6
 
7
- # Copy the requirements.txt file into the container
8
- COPY requirements.txt .
9
 
10
- # Install the Python dependencies
11
- RUN pip install --no-cache-dir -r requirements.txt
12
 
13
  # Install en_core_web_sm
14
  RUN pip install https://github.com/explosion/spacy-models/releases/download/en_core_web_sm-3.5.0/en_core_web_sm-3.5.0.tar.gz --user
15
 
16
- # Copy the rest of the application code into the container
17
- COPY . .
 
 
 
 
 
18
 
19
- # Expose the port that the app will run on
20
- EXPOSE 7860
 
 
 
21
 
22
  # Start the FastAPI app using Uvicorn
23
- CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8000"]
 
2
  FROM python:3.9
3
 
4
  # Set the working directory in the container
5
+ WORKDIR /code
6
 
7
+ # Copy the current directory contents into the container at /code
8
+ COPY ./requirements.txt /code/requirements.txt
9
 
10
+ # Install requirements.txt
11
+ RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt
12
 
13
  # Install en_core_web_sm
14
  RUN pip install https://github.com/explosion/spacy-models/releases/download/en_core_web_sm-3.5.0/en_core_web_sm-3.5.0.tar.gz --user
15
 
16
+ # Set up a new user named "user" with user ID 1000
17
+ RUN useradd -m -u 1000 user
18
+ # Switch to the "user" user
19
+ USER user
20
+ # Set home to the user's home directory
21
+ ENV HOME=/home/user \
22
+ PATH=/home/user/.local/bin:$PATH
23
 
24
+ # Set the working directory to the user's home directory
25
+ WORKDIR $HOME/app
26
+
27
+ # Copy the current directory contents into the container at $HOME/app setting the owner to the user
28
+ COPY --chown=user . $HOME/app
29
 
30
  # Start the FastAPI app using Uvicorn
31
+ CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]