File size: 800 Bytes
173818a
 
 
63b1417
 
 
173818a
 
 
6543f83
63b1417
6543f83
 
63b1417
6543f83
173818a
63b1417
173818a
 
 
 
 
63b1417
 
 
 
173818a
6543f83
173818a
 
 
6543f83
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
30
31
32
# Use an official Python runtime as the base image
FROM python:3.9-slim

# Create a non-root user
RUN useradd -m -u 1000 appuser

# Set working directory
WORKDIR /app

# Create a cache directory and set permissions
RUN mkdir -p /app/cache/huggingface && chown -R appuser:appuser /app

# Set environment variable for Hugging Face cache
ENV HF_HOME=/app/cache/huggingface

# Copy requirements file
COPY --chown=appuser:appuser requirements.txt .

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

# Copy the FastAPI application code
COPY --chown=appuser:appuser main.py .

# Switch to non-root user
USER appuser

# Expose port 7860 for the FastAPI app
EXPOSE 7860

# Command to run the application with Uvicorn
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]