Spaces:
Sleeping
Sleeping
Create Dockerfile
Browse files- Dockerfile +27 -0
Dockerfile
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Read the doc: https://huggingface.co/docs/hub/spaces-sdks-docker
|
| 2 |
+
# You will also find guides on how best to write your Dockerfile
|
| 3 |
+
|
| 4 |
+
# Use a Python base image (Python 3.12)
|
| 5 |
+
FROM python:3.12
|
| 6 |
+
|
| 7 |
+
# Create a user with UID 1000 (recommended for Docker containers)
|
| 8 |
+
RUN useradd -m -u 1000 user
|
| 9 |
+
|
| 10 |
+
# Switch to the non-root user
|
| 11 |
+
USER user
|
| 12 |
+
|
| 13 |
+
# Add the user's local bin directory to the PATH environment variable
|
| 14 |
+
ENV PATH="/home/user/.local/bin:$PATH"
|
| 15 |
+
|
| 16 |
+
# Set the working directory inside the container
|
| 17 |
+
WORKDIR /app
|
| 18 |
+
|
| 19 |
+
# Copy the requirements.txt file and install dependencies
|
| 20 |
+
COPY --chown=user ./requirements.txt requirements.txt
|
| 21 |
+
RUN pip install --no-cache-dir --upgrade -r requirements.txt
|
| 22 |
+
|
| 23 |
+
# Copy the entire content of your project into the container (application code, model, etc.)
|
| 24 |
+
COPY --chown=user . /app
|
| 25 |
+
|
| 26 |
+
# Start the FastAPI application using Uvicorn, serving it on port 7860 (Hugging Face Spaces defaults to this port)
|
| 27 |
+
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]
|