Spaces:
Paused
Paused
File size: 782 Bytes
7936e19 1c9f5b4 7936e19 1c9f5b4 7936e19 1c9f5b4 7936e19 1c9f5b4 c640f15 7936e19 |
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 |
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"] |