singhankur01 commited on
Commit
2df86db
·
verified ·
1 Parent(s): 44fbb91

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +51 -20
Dockerfile CHANGED
@@ -1,29 +1,60 @@
1
- # Base image
2
- FROM python:3.11-slim
3
 
4
- # Set environment variables
5
- ENV PYTHONDONTWRITEBYTECODE 1
6
- ENV PYTHONUNBUFFERED 1
7
 
8
- # Install OS dependencies
9
- RUN apt-get update && apt-get install -y \
10
- build-essential \
11
- curl \
12
- git \
13
- && rm -rf /var/lib/apt/lists/*
14
 
15
- # Create working directory
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
16
  WORKDIR /code
17
 
18
- # Install Python dependencies
19
- COPY requirements.txt /code/
20
- RUN pip install --no-cache-dir -r requirements.txt
21
 
22
- # Copy app code
23
- COPY . /code/
24
 
25
- # Expose port
26
- EXPOSE 7860
 
 
27
 
28
- # 🚀 Start FastAPI using Uvicorn
 
 
 
 
 
 
 
 
 
 
 
29
  CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]
 
 
1
+ # # Base image
2
+ # FROM python:3.11-slim
3
 
4
+ # # Set environment variables
5
+ # ENV PYTHONDONTWRITEBYTECODE 1
6
+ # ENV PYTHONUNBUFFERED 1
7
 
8
+ # # Install OS dependencies
9
+ # RUN apt-get update && apt-get install -y \
10
+ # build-essential \
11
+ # curl \
12
+ # git \
13
+ # && rm -rf /var/lib/apt/lists/*
14
 
15
+ # # Create working directory
16
+ # WORKDIR /code
17
+
18
+ # # Install Python dependencies
19
+ # COPY requirements.txt /code/
20
+ # RUN pip install --no-cache-dir -r requirements.txt
21
+
22
+ # # Copy app code
23
+ # COPY . /code/
24
+
25
+ # # Expose port
26
+ # EXPOSE 7860
27
+
28
+ # # 🚀 Start FastAPI using Uvicorn
29
+ # CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]
30
+ ## Use the official Python 3.9 image
31
+ FROM python:3.11
32
+
33
+ ## set the working directory to /code
34
  WORKDIR /code
35
 
36
+ ## Copy the current directory contents in the container at /code
37
+ COPY ./requirements.txt /code/requirements.txt
 
38
 
39
+ ## Install the requirements.txt
40
+ RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt
41
 
42
+ # Set up a new user named "user"
43
+ RUN useradd user
44
+ # Switch to the "user" user
45
+ USER user
46
 
47
+ # Set home to the user's home directory
48
+
49
+ ENV HOME=/home/user \
50
+ PATH=/home/user/.local/bin:$PATH
51
+
52
+ # Set the working directory to the user's home directory
53
+ WORKDIR $HOME/app
54
+
55
+ # Copy the current directory contents into the container at $HOME/app setting the owner to the user
56
+ COPY --chown=user . $HOME/app
57
+
58
+ ## Start the FASTAPI App on port 7860
59
  CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]
60
+