File size: 692 Bytes
a1dd175
 
 
 
 
 
 
4f089ce
64d95fb
f5371d9
4f089ce
a1dd175
 
 
b1eaaf5
 
f5371d9
a1dd175
 
b1eaaf5
 
 
 
a1dd175
 
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
# Use a lightweight Python image
FROM python:3.9

# Create a non-root user
RUN useradd -u 1000 user
ENV PATH="/home/user/.local/bin:$PATH"

# Set a writable cache directory for Hugging Face Transformers
ENV TRANSFORMERS_CACHE=/app/.cache
ENV HF_HOME=/app/.cache 

# Set the working directory inside the container
WORKDIR /app

# Copy the dependencies and install them as root
COPY requirements.txt .
RUN mkdir -p /app/.cache && chown -R user:user /app/.cache
RUN pip install --no-cache-dir -r requirements.txt

# Switch to the non-root user after installing dependencies
USER user
COPY . .

# Run the FastAPI app with Uvicorn
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]