Spaces:
Running
Running
hello
Browse files- Dockerfile +7 -10
Dockerfile
CHANGED
|
@@ -16,7 +16,6 @@ FROM python:3.9-slim
|
|
| 16 |
# Install runtime dependencies
|
| 17 |
RUN apt-get update && apt-get install -y \
|
| 18 |
curl \
|
| 19 |
-
git \
|
| 20 |
&& rm -rf /var/lib/apt/lists/* \
|
| 21 |
&& apt-get clean
|
| 22 |
|
|
@@ -26,18 +25,16 @@ COPY --from=builder /root/.local /root/.local
|
|
| 26 |
# Set working directory
|
| 27 |
WORKDIR /app
|
| 28 |
|
| 29 |
-
# Set environment variables
|
| 30 |
ENV PYTHONDONTWRITEBYTECODE=1 \
|
| 31 |
PYTHONUNBUFFERED=1 \
|
| 32 |
-
GRADIO_SERVER_NAME="0.0.0.0" \
|
| 33 |
-
GRADIO_SERVER_PORT=7860 \
|
| 34 |
PATH="/root/.local/bin:$PATH" \
|
| 35 |
TRANSFORMERS_CACHE=/app/model_cache \
|
| 36 |
HF_HOME=/app/hf_cache \
|
| 37 |
HUGGINGFACE_HUB_CACHE=/app/hf_cache
|
| 38 |
|
| 39 |
# Create cache directories with proper permissions
|
| 40 |
-
RUN mkdir -p /app/model_cache /app/hf_cache
|
| 41 |
|
| 42 |
# Copy application code
|
| 43 |
COPY . .
|
|
@@ -49,12 +46,12 @@ RUN useradd -m -u 1000 user && \
|
|
| 49 |
|
| 50 |
USER user
|
| 51 |
|
| 52 |
-
# Expose
|
| 53 |
-
EXPOSE 7860
|
| 54 |
|
| 55 |
# Health check
|
| 56 |
HEALTHCHECK --interval=30s --timeout=30s --start-period=90s --retries=3 \
|
| 57 |
-
CMD curl -f http://localhost:7860/
|
| 58 |
|
| 59 |
-
# Run
|
| 60 |
-
CMD ["
|
|
|
|
| 16 |
# Install runtime dependencies
|
| 17 |
RUN apt-get update && apt-get install -y \
|
| 18 |
curl \
|
|
|
|
| 19 |
&& rm -rf /var/lib/apt/lists/* \
|
| 20 |
&& apt-get clean
|
| 21 |
|
|
|
|
| 25 |
# Set working directory
|
| 26 |
WORKDIR /app
|
| 27 |
|
| 28 |
+
# Set environment variables
|
| 29 |
ENV PYTHONDONTWRITEBYTECODE=1 \
|
| 30 |
PYTHONUNBUFFERED=1 \
|
|
|
|
|
|
|
| 31 |
PATH="/root/.local/bin:$PATH" \
|
| 32 |
TRANSFORMERS_CACHE=/app/model_cache \
|
| 33 |
HF_HOME=/app/hf_cache \
|
| 34 |
HUGGINGFACE_HUB_CACHE=/app/hf_cache
|
| 35 |
|
| 36 |
# Create cache directories with proper permissions
|
| 37 |
+
RUN mkdir -p /app/model_cache /app/hf_cache
|
| 38 |
|
| 39 |
# Copy application code
|
| 40 |
COPY . .
|
|
|
|
| 46 |
|
| 47 |
USER user
|
| 48 |
|
| 49 |
+
# Expose HuggingFace Spaces port (7860)
|
| 50 |
+
EXPOSE 7860
|
| 51 |
|
| 52 |
# Health check
|
| 53 |
HEALTHCHECK --interval=30s --timeout=30s --start-period=90s --retries=3 \
|
| 54 |
+
CMD curl -f http://localhost:7860/ || curl -f http://localhost:7860/docs || exit 1
|
| 55 |
|
| 56 |
+
# Run FastAPI application on port 7860 for HuggingFace Spaces
|
| 57 |
+
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]
|