Spaces:
Sleeping
Sleeping
FROM python:3.9 | |
WORKDIR /code | |
# Create a non-root user to run the app | |
RUN useradd -m appuser | |
# Create cache directories and set permissions | |
RUN mkdir -p /home/appuser/cache /home/appuser/hf_home && \ | |
chown -R appuser:appuser /home/appuser/cache /home/appuser/hf_home | |
# Set environment variables for the cache | |
ENV TRANSFORMERS_CACHE=/home/appuser/cache | |
ENV HF_HOME=/home/appuser/hf_home | |
COPY ./requirements.txt /code/requirements.txt | |
RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt | |
COPY . /code | |
# Give ownership of the code to appuser | |
RUN chown -R appuser:appuser /code | |
EXPOSE 7860 | |
# Switch to appuser for running the application | |
USER appuser | |
CMD ["python", "app.py"] |