khalednabawi11 commited on
Commit
dae72be
·
verified ·
1 Parent(s): dd4b311

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +10 -15
Dockerfile CHANGED
@@ -1,9 +1,5 @@
1
  FROM python:3.9-slim
2
 
3
- # Create a non-root user
4
- RUN useradd -m appuser
5
-
6
- # Set the working directory
7
  WORKDIR /code
8
 
9
  # Install system dependencies
@@ -13,13 +9,15 @@ RUN apt-get update && apt-get install -y \
13
  curl \
14
  && rm -rf /var/lib/apt/lists/*
15
 
16
- # Copy requirements file and install Python dependencies
17
- COPY app/requirements.txt .
18
- RUN pip install --no-cache-dir -r app/requirements.txt
 
 
19
 
20
- # Copy the application code
21
  COPY app /code/app
22
- COPY app/main.py .
23
 
24
  # Create models and cache directories and set correct permissions
25
  RUN mkdir -p /code/models/.cache/huggingface && \
@@ -29,11 +27,8 @@ RUN mkdir -p /code/models/.cache/huggingface && \
29
  ENV HOST=0.0.0.0
30
  ENV PORT=7860
31
 
32
- # Expose the port
33
  EXPOSE 7860
34
 
35
- # Switch to the non-root user
36
- USER appuser
37
-
38
- # Command to run the FastAPI app
39
- CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "7860"]
 
1
  FROM python:3.9-slim
2
 
 
 
 
 
3
  WORKDIR /code
4
 
5
  # Install system dependencies
 
9
  curl \
10
  && rm -rf /var/lib/apt/lists/*
11
 
12
+ # Copy requirements first to leverage Docker cache
13
+ COPY requirements.txt .
14
+
15
+ # Install Python dependencies
16
+ RUN pip install --no-cache-dir -r requirements.txt
17
 
18
+ # Copy the application code (excluding models)
19
  COPY app /code/app
20
+ COPY main.py .
21
 
22
  # Create models and cache directories and set correct permissions
23
  RUN mkdir -p /code/models/.cache/huggingface && \
 
27
  ENV HOST=0.0.0.0
28
  ENV PORT=7860
29
 
30
+ # Expose the port that FastAPI will run on
31
  EXPOSE 7860
32
 
33
+ # Command to run the FastAPI application
34
+ CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "7860"]