Download Dockerfile from imkrish/certificate-generator: direct link, hf CLI and curl.
- Browser
- Download file 1.52 kB
-
https://huggingface.co/spaces/imkrish/certificate-generator/resolve/main/Dockerfile
- Command line
-
hf download hf://spaces/imkrish/certificate-generator/Dockerfile
-
curl -L -o Dockerfile https://huggingface.co/spaces/imkrish/certificate-generator/resolve/main/Dockerfile
1.52 kB
| # Multi-stage build for ML Certificate Generator Service | |
| FROM python:3.10-slim as builder | |
| # Set working directory | |
| WORKDIR /app | |
| # Install system dependencies required for PIL/Pillow | |
| RUN apt-get update && apt-get install -y \ | |
| gcc \ | |
| g++ \ | |
| make \ | |
| libfreetype6-dev \ | |
| libjpeg-dev \ | |
| libpng-dev \ | |
| zlib1g-dev \ | |
| && rm -rf /var/lib/apt/lists/* | |
| # Copy requirements first for better caching | |
| COPY requirements.txt . | |
| # Install Python dependencies | |
| RUN pip install --no-cache-dir --upgrade pip && \ | |
| pip install --no-cache-dir -r requirements.txt | |
| # Final stage | |
| FROM python:3.10-slim | |
| # Set working directory | |
| WORKDIR /app | |
| # Install runtime dependencies for PIL/Pillow | |
| RUN apt-get update && apt-get install -y \ | |
| libfreetype6 \ | |
| libjpeg62-turbo \ | |
| libpng16-16 \ | |
| curl \ | |
| && rm -rf /var/lib/apt/lists/* | |
| # Copy Python packages from builder | |
| COPY --from=builder /usr/local/lib/python3.10/site-packages /usr/local/lib/python3.10/site-packages | |
| COPY --from=builder /usr/local/bin /usr/local/bin | |
| # Copy application code | |
| COPY . . | |
| # Create necessary directories | |
| RUN mkdir -p uploads fonts | |
| # Set environment variables | |
| ENV PYTHONUNBUFFERED=1 | |
| ENV PYTHONDONTWRITEBYTECODE=1 | |
| ENV LOG_LEVEL=INFO | |
| # Expose port | |
| EXPOSE 7860 | |
| # Health check | |
| HEALTHCHECK --interval=30s --timeout=10s --start-period=15s --retries=3 \ | |
| CMD curl -f http://localhost:7860/health || exit 1 | |
| # Run the application with uvicorn | |
| CMD ["uvicorn", "api_main:app", "--host", "0.0.0.0", "--port", "7860", "--log-level", "info"] | |