File size: 667 Bytes
9e88f57
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7856ed7
9e88f57
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# Use official Python slim image for a smaller footprint
FROM python:3.12-slim

# Set environment variables for security and performance
ENV PYTHONDONTWRITEBYTECODE=1 \
    PYTHONUNBUFFERED=1 \
    PIP_NO_CACHE_DIR=1

# Set working directory
WORKDIR /app

# Copy requirements.txt first for caching
COPY requirements.txt .

# Install dependencies
RUN pip install --no-cache-dir -r requirements.txt

# Copy the server code
COPY app.py

# Create a non-root user for security
RUN useradd -m appuser && chown -R appuser:appuser /app
USER appuser

# Expose port 8000
EXPOSE 7860

# Command to run the server
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]