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

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +22 -22
Dockerfile CHANGED
@@ -1,29 +1,29 @@
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"]
 
1
+ # Use official lightweight Python image
2
+ FROM python:3.10-slim
3
 
4
+ # Set environment variables
5
+ ENV PYTHONDONTWRITEBYTECODE=1
6
+ ENV PYTHONUNBUFFERED=1
 
 
 
7
 
8
+ # Set working directory
9
+ WORKDIR /app
 
10
 
11
+ # Install system dependencies
12
+ RUN apt-get update && apt-get install -y \
13
+ libgl1-mesa-glx \
14
+ libglib2.0-0 \
15
+ && rm -rf /var/lib/apt/lists/*
16
 
17
+ # Install Python dependencies
18
+ COPY requirements.txt .
19
+ RUN pip install --upgrade pip
20
+ RUN pip install --no-cache-dir -r requirements.txt
21
 
22
+ # Copy project files
23
+ COPY . .
24
 
25
+ # Expose port
26
+ EXPOSE 8000
27
 
28
+ # Start Uvicorn server
29
+ CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8000"]