Spaces:
Sleeping
Sleeping
Commit ·
c27fef7
1
Parent(s): 6ad81c6
Final Update: Optimized FastAPI backend with root landing page for Vercel frontend connectivity
Browse files- Dockerfile +12 -13
Dockerfile
CHANGED
|
@@ -1,31 +1,30 @@
|
|
| 1 |
-
FROM python:3.
|
| 2 |
|
| 3 |
-
# Install system dependencies for OpenCV and
|
| 4 |
RUN apt-get update && apt-get install -y \
|
| 5 |
-
libgl1
|
| 6 |
libglib2.0-0 \
|
|
|
|
|
|
|
|
|
|
| 7 |
&& rm -rf /var/lib/apt/lists/*
|
| 8 |
|
| 9 |
-
# Set up
|
| 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 |
-
#
|
| 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
|
| 25 |
COPY --chown=user . .
|
| 26 |
|
| 27 |
-
# Hugging Face
|
| 28 |
EXPOSE 7860
|
| 29 |
|
| 30 |
-
#
|
| 31 |
-
CMD ["uvicorn", "
|
|
|
|
| 1 |
+
FROM python:3.11-slim
|
| 2 |
|
| 3 |
+
# Install system dependencies for OpenCV and ML
|
| 4 |
RUN apt-get update && apt-get install -y \
|
| 5 |
+
libgl1 \
|
| 6 |
libglib2.0-0 \
|
| 7 |
+
libsm6 \
|
| 8 |
+
libxrender1 \
|
| 9 |
+
libxext6 \
|
| 10 |
&& rm -rf /var/lib/apt/lists/*
|
| 11 |
|
| 12 |
+
# Set up user
|
| 13 |
RUN useradd -m -u 1000 user
|
| 14 |
USER user
|
| 15 |
ENV PATH="/home/user/.local/bin:$PATH"
|
|
|
|
|
|
|
| 16 |
WORKDIR /home/user/app
|
| 17 |
|
| 18 |
+
# Install Python dependencies
|
| 19 |
COPY --chown=user requirements.txt .
|
|
|
|
|
|
|
| 20 |
RUN pip install --no-cache-dir --upgrade pip
|
| 21 |
RUN pip install --no-cache-dir -r requirements.txt
|
| 22 |
|
| 23 |
+
# Copy source code
|
| 24 |
COPY --chown=user . .
|
| 25 |
|
| 26 |
+
# Hugging Face usually expects 7860
|
| 27 |
EXPOSE 7860
|
| 28 |
|
| 29 |
+
# Run FastAPI
|
| 30 |
+
CMD ["uvicorn", "classifier_service.api:app", "--host", "0.0.0.0", "--port", "7860"]
|