Spaces:
Running
Running
File size: 793 Bytes
7af3f30 33e4a89 7af3f30 33e4a89 7af3f30 33e4a89 7af3f30 33e4a89 7af3f30 33e4a89 7af3f30 33e4a89 7af3f30 33e4a89 7af3f30 33e4a89 7af3f30 33e4a89 7af3f30 |
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 34 |
# Use Python 3.10 slim
FROM python:3.10-slim
# Create a non-root user with ID 1000
RUN useradd -m -u 1000 user
# Switch to non-root
USER user
# Env variables
ENV HOME=/home/user \
PATH=/home/user/.local/bin:$PATH
# Working directory
WORKDIR $HOME/app
# Copy requirements first for caching
COPY --chown=user ./requirements.txt requirements.txt
# Install dependencies
RUN pip install --no-cache-dir --upgrade -r requirements.txt
# Copy app code, ensure user owns everything
COPY --chown=user . $HOME/app
# Make blogs.json writable
RUN touch $HOME/app/blogs.json && chmod 664 $HOME/app/blogs.json
# Expose HF Spaces default port
EXPOSE 7860
# Run app (ensure your FastAPI app instance is `app` in app.py or main.py)
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]
|