Spaces:
Sleeping
Sleeping
Commit ·
d780007
1
Parent(s): 964d30e
chore: add Dockerfile for Hugging Face Spaces deployment
Browse files- Dockerfile +31 -0
Dockerfile
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
FROM python:3.10-slim
|
| 2 |
+
|
| 3 |
+
# Install system dependencies for OpenCV and scikit-image
|
| 4 |
+
RUN apt-get update && apt-get install -y \
|
| 5 |
+
libgl1-mesa-glx \
|
| 6 |
+
libglib2.0-0 \
|
| 7 |
+
&& rm -rf /var/lib/apt/lists/*
|
| 8 |
+
|
| 9 |
+
# Set up a new user named "user" with user ID 1000
|
| 10 |
+
RUN useradd -m -u 1000 user
|
| 11 |
+
USER user
|
| 12 |
+
ENV PATH="/home/user/.local/bin:$PATH"
|
| 13 |
+
|
| 14 |
+
# Set the working directory to the user's home directory
|
| 15 |
+
WORKDIR /home/user/app
|
| 16 |
+
|
| 17 |
+
# Copy the requirements file into the container
|
| 18 |
+
COPY --chown=user requirements.txt .
|
| 19 |
+
|
| 20 |
+
# Install the Python dependencies
|
| 21 |
+
RUN pip install --no-cache-dir --upgrade pip
|
| 22 |
+
RUN pip install --no-cache-dir -r requirements.txt
|
| 23 |
+
|
| 24 |
+
# Copy the rest of the application code into the container
|
| 25 |
+
COPY --chown=user . .
|
| 26 |
+
|
| 27 |
+
# Hugging Face Spaces expects the app to run on port 7860
|
| 28 |
+
EXPOSE 7860
|
| 29 |
+
|
| 30 |
+
# Command to run the FastAPI application
|
| 31 |
+
CMD ["uvicorn", "bacterial-classifier.api:app", "--host", "0.0.0.0", "--port", "7860"]
|