Spaces:
Paused
Paused
File size: 1,888 Bytes
1291bc4 ecb8e64 1291bc4 a891b12 1291bc4 ecb8e64 1291bc4 ecb8e64 1291bc4 ecb8e64 1291bc4 ecb8e64 1291bc4 6be2496 1291bc4 ecb8e64 1291bc4 ecb8e64 1291bc4 ecb8e64 a891b12 ecb8e64 1291bc4 603a5b3 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 | # Multi-stage Docker build untuk FunCaptcha Server di HF Spaces
# Optimasi untuk ukuran minimal dan performa maksimal
FROM python:3.11-slim as base
# Install system dependencies + tools untuk ONNX Runtime fix
RUN apt-get update && apt-get install -y \
curl \
libglib2.0-0 \
libgomp1 \
gcc \
g++ \
make \
cmake \
&& rm -rf /var/lib/apt/lists/* \
&& apt-get clean
# Set working directory
WORKDIR /app
# Copy requirements dan installer scripts
COPY requirements.txt .
COPY install-onnx.py .
# Make installer executable
RUN chmod +x install-onnx.py
# Install Python dependencies tanpa ONNX Runtime dulu
RUN pip install --no-cache-dir --upgrade pip && \
pip install --no-cache-dir fastapi==0.104.1 uvicorn[standard]==0.24.0 opencv-python-headless==4.8.0.76 numpy==1.24.3 pillow==10.0.1 pyyaml==6.0.1 python-multipart==0.0.6 python-jose[cryptography]==3.3.0 structlog==23.2.0 && \
pip cache purge
# Try aggressive ONNX Runtime installation (non-blocking)
RUN python install-onnx.py || echo "⚠️ ONNX Runtime installation failed, continuing with degraded mode"
# Copy aplikasi
COPY . .
# Set environment variables untuk optimasi + Aggressive ONNX Runtime fix
ENV PYTHONUNBUFFERED=1
ENV PYTHONDONTWRITEBYTECODE=1
ENV OMP_NUM_THREADS=1
ENV MKL_NUM_THREADS=1
ENV OPENBLAS_NUM_THREADS=1
ENV NUMEXPR_NUM_THREADS=1
ENV ORT_DISABLE_ALL_OPTIMIZATION=1
ENV ONNXRUNTIME_LOG_SEVERITY_LEVEL=3
ENV ORT_ENABLE_CPU_FP16=0
ENV ORT_DISABLE_CPU_EP_FALL_BACK=1
ENV ORT_FORCE_DISABLE_CPU_FP16=1
# Expose port
EXPOSE 7860
# Health check untuk monitoring
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
CMD curl -f http://localhost:7860/health || exit 1
# Run aplikasi
CMD ["python", "-m", "uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860", "--workers", "1"]
|