File size: 839 Bytes
5d65c37
 
adad4ac
 
5d65c37
adad4ac
 
5d65c37
 
 
 
 
 
adad4ac
 
 
 
 
5d65c37
adad4ac
 
 
5d65c37
adad4ac
 
5d65c37
 
adad4ac
 
 
 
5d65c37
adad4ac
 
5d65c37
adad4ac
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
33
34
35
36
37
# Dockerfile

FROM python:3.9-slim

# Install dependencies
RUN apt-get update && apt-get install -y git git-lfs && git lfs install

# Set environment variables
ENV HF_HOME="/home/appuser/.cache/huggingface"
ENV TRANSFORMERS_CACHE="/home/appuser/.cache/huggingface/transformers"
ENV HF_DATASETS_CACHE="/home/appuser/.cache/huggingface/datasets"

# Create a non-root user
RUN useradd -ms /bin/bash appuser

# Set the working directory
WORKDIR /home/appuser/app

# Copy requirements and install
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt

# Copy the application code
COPY . .

# Change ownership
RUN chown -R appuser:appuser /home/appuser

# Switch to non-root user
USER appuser

# Expose the port
EXPOSE 7860

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