Spaces:
Sleeping
Sleeping
Commit
·
2393be4
1
Parent(s):
5c2587b
Updated container'
Browse files- Dockerfile +39 -0
Dockerfile
CHANGED
|
@@ -0,0 +1,39 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Use an official Python image
|
| 2 |
+
FROM python:3.12-slim
|
| 3 |
+
|
| 4 |
+
# Create a non-root user with UID 1000
|
| 5 |
+
RUN useradd -m -u 1000 user
|
| 6 |
+
|
| 7 |
+
# Create a data/cache directory with open permissions
|
| 8 |
+
RUN mkdir -p /data/.cache/huggingface && \
|
| 9 |
+
chown -R user:user /data && \
|
| 10 |
+
chmod -R 777 /data
|
| 11 |
+
|
| 12 |
+
# Set environment variables for Hugging Face cache
|
| 13 |
+
ENV HF_HOME=/data/.cache/huggingface \
|
| 14 |
+
TRANSFORMERS_CACHE=/data/.cache/huggingface/transformers \
|
| 15 |
+
HF_DATASETS_CACHE=/data/.cache/huggingface/datasets
|
| 16 |
+
|
| 17 |
+
# Switch to the non-root user
|
| 18 |
+
USER user
|
| 19 |
+
|
| 20 |
+
# Set working directory for the user
|
| 21 |
+
WORKDIR /home/user/app
|
| 22 |
+
|
| 23 |
+
# Ensure pip packages go to user space
|
| 24 |
+
ENV PATH=/home/user/.local/bin:$PATH
|
| 25 |
+
|
| 26 |
+
# Upgrade pip (runs as user)
|
| 27 |
+
RUN pip install --no-cache-dir --upgrade pip
|
| 28 |
+
|
| 29 |
+
# Copy code into the container, set ownership
|
| 30 |
+
COPY --chown=user . .
|
| 31 |
+
|
| 32 |
+
# Install dependencies (will go to ~/.local)
|
| 33 |
+
RUN pip install --no-cache-dir -r requirements.txt
|
| 34 |
+
|
| 35 |
+
# Expose port
|
| 36 |
+
EXPOSE 7860
|
| 37 |
+
|
| 38 |
+
# Run the FastAPI app
|
| 39 |
+
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]
|