Spaces:
Build error
Build error
Upload folder using huggingface_hub
Browse files- Dockerfile +17 -14
Dockerfile
CHANGED
|
@@ -3,31 +3,34 @@ FROM python:3.9-slim
|
|
| 3 |
# Set working directory
|
| 4 |
WORKDIR /app
|
| 5 |
|
| 6 |
-
# Install system dependencies
|
| 7 |
-
RUN apt-get update && apt-get install -y \
|
| 8 |
-
gcc \
|
| 9 |
-
curl \
|
| 10 |
&& rm -rf /var/lib/apt/lists/*
|
| 11 |
|
|
|
|
|
|
|
|
|
|
| 12 |
# Copy requirements first for better caching
|
| 13 |
-
COPY
|
| 14 |
|
| 15 |
# Install Python dependencies
|
| 16 |
-
RUN pip install --no-cache-dir -
|
|
|
|
| 17 |
|
| 18 |
# Copy application files
|
| 19 |
-
COPY . .
|
| 20 |
|
| 21 |
-
#
|
| 22 |
-
RUN useradd -m -u 1000 user
|
| 23 |
USER user
|
| 24 |
|
| 25 |
# Expose port
|
| 26 |
EXPOSE 7860
|
| 27 |
|
| 28 |
-
# Health check
|
| 29 |
-
HEALTHCHECK --interval=30s --timeout=30s --start-period=5s --retries=3 \
|
| 30 |
-
CMD curl -f http://localhost:7860/ || exit 1
|
| 31 |
|
| 32 |
-
# Run the application
|
| 33 |
-
CMD ["
|
|
|
|
| 3 |
# Set working directory
|
| 4 |
WORKDIR /app
|
| 5 |
|
| 6 |
+
# Install system dependencies
|
| 7 |
+
RUN apt-get update && apt-get install -y \\
|
| 8 |
+
gcc \\
|
| 9 |
+
curl \\
|
| 10 |
&& rm -rf /var/lib/apt/lists/*
|
| 11 |
|
| 12 |
+
# Create non-root user for security
|
| 13 |
+
RUN useradd -m -u 1000 user
|
| 14 |
+
|
| 15 |
# Copy requirements first for better caching
|
| 16 |
+
COPY --chown=user:user requirements_fastapi.txt requirements.txt
|
| 17 |
|
| 18 |
# Install Python dependencies
|
| 19 |
+
RUN pip install --no-cache-dir --upgrade pip && \\
|
| 20 |
+
pip install --no-cache-dir -r requirements.txt
|
| 21 |
|
| 22 |
# Copy application files
|
| 23 |
+
COPY --chown=user:user . .
|
| 24 |
|
| 25 |
+
# Switch to non-root user
|
|
|
|
| 26 |
USER user
|
| 27 |
|
| 28 |
# Expose port
|
| 29 |
EXPOSE 7860
|
| 30 |
|
| 31 |
+
# Health check for FastAPI
|
| 32 |
+
HEALTHCHECK --interval=30s --timeout=30s --start-period=5s --retries=3 \\
|
| 33 |
+
CMD curl -f http://localhost:7860/docs || exit 1
|
| 34 |
|
| 35 |
+
# Run the FastAPI application with uvicorn
|
| 36 |
+
CMD [\"uvicorn\", \"app_fastapi:app\", \"--host\", \"0.0.0.0\", \"--port\", \"7860\"]
|