Spaces:
Sleeping
Sleeping
Upload folder using huggingface_hub
Browse files- Dockerfile +44 -0
Dockerfile
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
This removes the configuration error.
|
| 3 |
+
|
| 4 |
+
---
|
| 5 |
+
|
| 6 |
+
## 2️⃣ Dockerfile (adapted for FastAPI app)
|
| 7 |
+
|
| 8 |
+
Use your existing Dockerfile but tweaked slightly for Spaces + FastAPI:
|
| 9 |
+
|
| 10 |
+
```dockerfile
|
| 11 |
+
# Use a standard Python 3.11 slim image
|
| 12 |
+
FROM python:3.11-slim
|
| 13 |
+
|
| 14 |
+
# Set up a new user named "user" with user ID 1000 (required by HF Spaces)
|
| 15 |
+
RUN useradd -m -u 1000 user
|
| 16 |
+
|
| 17 |
+
# Switch to the "user" user
|
| 18 |
+
USER user
|
| 19 |
+
|
| 20 |
+
# Set home to the user's home directory
|
| 21 |
+
ENV HOME=/home/user \
|
| 22 |
+
PATH=/home/user/.local/bin:$PATH
|
| 23 |
+
|
| 24 |
+
# Set the working directory to the user's home directory
|
| 25 |
+
WORKDIR $HOME/app
|
| 26 |
+
|
| 27 |
+
# Copy the requirements file first to leverage Docker layer caching
|
| 28 |
+
COPY --chown=user requirements.txt .
|
| 29 |
+
|
| 30 |
+
# Install all your Python dependencies
|
| 31 |
+
RUN pip install --no-cache-dir --upgrade pip && \
|
| 32 |
+
pip install --no-cache-dir -r requirements.txt
|
| 33 |
+
|
| 34 |
+
# Copy all your project files into the container with proper ownership
|
| 35 |
+
COPY --chown=user . .
|
| 36 |
+
|
| 37 |
+
# Make our startup script executable
|
| 38 |
+
RUN chmod +x ./start.sh
|
| 39 |
+
|
| 40 |
+
# Hugging Face Spaces will set PORT env; default to 7860 if not set
|
| 41 |
+
EXPOSE 7860
|
| 42 |
+
|
| 43 |
+
# Run the startup script when the container starts
|
| 44 |
+
CMD ["./start.sh"]
|