Spaces:
Sleeping
Sleeping
Commit ·
8327a4f
1
Parent(s): be75532
fix: use port 7860 for Hugging Face Spaces compatibility
Browse filesHugging Face Spaces expects applications to run on port 7860.
Updated EXPOSE and uvicorn port from 8000 to 7860.
Co-Authored-By: Claude (glm-4.7) <noreply@anthropic.com>
- Dockerfile +7 -6
Dockerfile
CHANGED
|
@@ -26,7 +26,8 @@ FROM python:3.13-slim
|
|
| 26 |
# Set environment variables
|
| 27 |
ENV PYTHONUNBUFFERED=1 \
|
| 28 |
PYTHONDONTWRITEBYTECODE=1 \
|
| 29 |
-
PATH="/app/.venv/bin:$PATH"
|
|
|
|
| 30 |
|
| 31 |
# Create non-root user
|
| 32 |
RUN groupadd -r appuser -g 1000 && \
|
|
@@ -59,12 +60,12 @@ COPY --chown=appuser:appuser uvicorn_config.py .
|
|
| 59 |
# Switch to non-root user
|
| 60 |
USER appuser
|
| 61 |
|
| 62 |
-
# Expose port
|
| 63 |
-
EXPOSE
|
| 64 |
|
| 65 |
# Health check
|
| 66 |
HEALTHCHECK --interval=30s --timeout=3s --start-period=10s --retries=3 \
|
| 67 |
-
CMD curl -f http://localhost:
|
| 68 |
|
| 69 |
-
# Run the application with uvicorn
|
| 70 |
-
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "
|
|
|
|
| 26 |
# Set environment variables
|
| 27 |
ENV PYTHONUNBUFFERED=1 \
|
| 28 |
PYTHONDONTWRITEBYTECODE=1 \
|
| 29 |
+
PATH="/app/.venv/bin:$PATH" \
|
| 30 |
+
PORT=7860
|
| 31 |
|
| 32 |
# Create non-root user
|
| 33 |
RUN groupadd -r appuser -g 1000 && \
|
|
|
|
| 60 |
# Switch to non-root user
|
| 61 |
USER appuser
|
| 62 |
|
| 63 |
+
# Expose port 7860 (Hugging Face Spaces default)
|
| 64 |
+
EXPOSE 7860
|
| 65 |
|
| 66 |
# Health check
|
| 67 |
HEALTHCHECK --interval=30s --timeout=3s --start-period=10s --retries=3 \
|
| 68 |
+
CMD curl -f http://localhost:7860/health || exit 1
|
| 69 |
|
| 70 |
+
# Run the application with uvicorn on port 7860
|
| 71 |
+
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]
|