Spaces:
Paused
Paused
FROM python:3.9 | |
# Create a non-root user | |
RUN useradd -m -u 1000 user | |
# Create cache directory and set permissions | |
RUN mkdir -p /home/user/.cache/huggingface && \ | |
mkdir -p /home/user/.cache/torch && \ | |
chown -R user:user /home/user/.cache | |
# Set environment variables | |
ENV TRANSFORMERS_CACHE=/home/user/.cache/huggingface | |
ENV TORCH_HOME=/home/user/.cache/torch | |
ENV HF_HOME=/home/user/.cache/huggingface | |
WORKDIR /code | |
# Copy and install requirements | |
COPY ./requirements.txt /code/requirements.txt | |
RUN pip install --no-cache-dir -r requirements.txt | |
# Copy application code | |
COPY ./app.py /code/app.py | |
# Change ownership of the application directory | |
RUN chown -R user:user /code | |
# Switch to non-root user | |
USER user | |
# Run the application | |
EXPOSE 7860 | |
CMD ["python", "app.py"] |