1MR commited on
Commit
92254c0
·
verified ·
1 Parent(s): f3f8001

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +28 -19
Dockerfile CHANGED
@@ -1,21 +1,30 @@
1
- # Use official Python image as a base
2
- FROM python:3.9-slim
 
 
 
 
 
 
 
 
 
 
 
 
3
 
4
- # Set environment variables
5
- ENV PYTHONDONTWRITEBYTECODE 1
6
- ENV PYTHONUNBUFFERED 1
7
-
8
- # Set working directory
9
- WORKDIR /app
10
-
11
- # Copy the FastAPI app and model
12
- COPY . /app
13
 
14
- # Install required libraries
15
- RUN pip install --no-cache-dir -r requirements.txt
16
-
17
- # Expose the port for the app
18
- EXPOSE 8000
19
-
20
- # Command to run the app
21
- CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]
 
 
 
 
 
1
+ # Use the official Python 3.9 image
2
+ FROM python:3.9
3
+
4
+ # Set the working directory to /code
5
+ WORKDIR /code
6
+
7
+ # Copy the requirements file
8
+ COPY ./requirements.txt /code/requirements.txt
9
+
10
+ # Install dependencies from requirements.txt
11
+ RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt
12
+
13
+ # Set up a new user named "user" with user ID 1000
14
+ RUN useradd -m -u 1000 user
15
 
16
+ # Switch to the "user" user
17
+ USER user
 
 
 
 
 
 
 
18
 
19
+ # Set environment variables
20
+ ENV HOME=/home/user
21
+ ENV PATH=$HOME/.local/bin:$PATH
22
+
23
+ # Set the working directory to the user's home directory
24
+ WORKDIR $HOME/app
25
+
26
+ # Copy the application code and set ownership to the user
27
+ COPY --chown=user . $HOME/app
28
+
29
+ # Start the FastAPI app
30
+ CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]