Zeggai Abdellah commited on
Commit
1a45b42
·
1 Parent(s): 4222139

fix dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +17 -21
Dockerfile CHANGED
@@ -1,32 +1,28 @@
1
- # Use Python 3.11 slim image
2
- FROM python:3.11-slim
3
 
4
  # Set working directory
5
- WORKDIR /app
6
 
7
- # Install system dependencies
8
- RUN apt-get update && apt-get install -y \
9
- build-essential \
10
- curl \
11
- && rm -rf /var/lib/apt/lists/*
12
 
13
- # Copy requirements first (for better caching)
14
- COPY requirements.txt .
15
 
16
- # Install Python dependencies
17
- RUN pip install --no-cache-dir -r requirements.txt
 
 
18
 
19
- # Copy your application files
20
- COPY . .
21
 
22
- # Create necessary directories if they don't exist
23
- RUN mkdir -p data chroma_db_multilingual
24
 
25
- # Set environment variables
26
- ENV PYTHONPATH=/app
27
- ENV PYTHONUNBUFFERED=1
28
-
29
- # Expose the port that FastAPI will run on
30
  EXPOSE 7860
31
 
 
32
  CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]
 
1
+ # Use a Python 3.9 base image
2
+ FROM python:3.9-slim
3
 
4
  # Set working directory
5
+ WORKDIR /code
6
 
7
+ # Copy requirements file
8
+ COPY ./requirements.txt /code/requirements.txt
 
 
 
9
 
10
+ # Install dependencies
11
+ RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt
12
 
13
+ # Create a non-root user for security
14
+ RUN useradd -m -u 1000 user
15
+ USER user
16
+ ENV HOME=/home/user PATH=/home/user/.local/bin:$PATH
17
 
18
+ # Set app directory
19
+ WORKDIR $HOME/app
20
 
21
+ # Copy all project files
22
+ COPY --chown=user . $HOME/app
23
 
24
+ # Expose port 7860 (Hugging Face default)
 
 
 
 
25
  EXPOSE 7860
26
 
27
+ # Run the FastAPI app with uvicorn
28
  CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]