MISSAOUI commited on
Commit
5286c73
·
verified ·
1 Parent(s): db34774

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +8 -27
Dockerfile CHANGED
@@ -1,35 +1,16 @@
1
- FROM python:3.12.4-slim
2
-
3
- # Set environment variables for cache and Python
4
- ENV PYTHONUNBUFFERED=1 \
5
- PYTHONDONTWRITEBYTECODE=1 \
6
- PIP_NO_CACHE_DIR=1 \
7
- HF_HOME=/app/.cache/huggingface \
8
- TRANSFORMERS_CACHE=/app/.cache/huggingface \
9
- TORCH_HOME=/app/.cache/torch
10
-
11
- # Create non-root user and set up directories
12
- RUN useradd -m appuser && \
13
- mkdir -p /app/.cache/huggingface /app/.cache/torch && \
14
- chown -R appuser:appuser /app
15
 
16
  WORKDIR /app
17
 
18
- # Copy requirements first for better layer caching
19
  COPY requirements.txt .
 
20
 
21
- # Install dependencies as root
22
- RUN pip install --no-cache-dir --upgrade pip && \
23
- pip install --no-cache-dir -r requirements.txt
24
-
25
- # Copy application code
26
- COPY --chown=appuser:appuser . .
27
 
28
- # Switch to non-root user
29
- USER appuser
30
 
31
- # Expose the port the app runs on
32
- EXPOSE 7860
33
 
34
- # Command to run the application
35
- CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]
 
1
+ FROM python:3.10-slim
 
 
 
 
 
 
 
 
 
 
 
 
 
2
 
3
  WORKDIR /app
4
 
 
5
  COPY requirements.txt .
6
+ RUN pip install --no-cache-dir -r requirements.txt
7
 
8
+ COPY app/ ./app/
 
 
 
 
 
9
 
10
+ # Create cache directory with proper permissions
11
+ RUN mkdir -p /app/cache
12
 
13
+ ENV PORT 7860
14
+ EXPOSE $PORT
15
 
16
+ CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "7860"]