File size: 587 Bytes
974c440
c629c02
 
974c440
c629c02
 
974c440
 
c629c02
974c440
297ce93
c629c02
974c440
 
 
 
 
 
c629c02
974c440
c629c02
 
974c440
 
 
297ce93
974c440
 
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 lightweight Python base
FROM python:3.10-slim

# Set working directory
WORKDIR /app

# Copy files
COPY . .

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

# Create cache directory and make it writable for non-root
RUN mkdir -p /app/hf_cache && chmod -R 777 /app/hf_cache

# Set environment variables for Hugging Face cache
ENV HF_HOME=/app/hf_cache
ENV TRANSFORMERS_CACHE=/app/hf_cache

# Expose Space port
EXPOSE 7860

# Switch to non-root user
RUN useradd -m appuser
USER appuser

# Run Flask directly (no Gunicorn)
CMD ["python", "api_inference.py"]