|
| 1 | +# syntax=docker/dockerfile:1 |
| 2 | +# PP-OCR ML Backend for Label Studio (GPU version) |
| 3 | +# |
| 4 | +# Uses the official PaddleX Docker image which includes |
| 5 | +# PaddlePaddle and PaddleX pre-installed. |
| 6 | +# |
| 7 | +# Build arguments: |
| 8 | +# CUDA_VERSION: cuda11.8 (default) or cuda12.6 |
| 9 | +# TEST_ENV: Set to "true" to install test dependencies |
| 10 | + |
| 11 | +ARG CUDA_VERSION=cuda11.8 |
| 12 | + |
| 13 | +# GPU with CUDA 11.8 (default) |
| 14 | +FROM ccr-2vdh3abv-pub.cnc.bj.baidubce.com/paddlex/paddlex:paddlex3.1.2-paddlepaddle3.0.0-gpu-cuda11.8-cudnn8.9-trt8.6 AS gpu-cuda11.8 |
| 15 | + |
| 16 | +# GPU with CUDA 12.6 |
| 17 | +FROM ccr-2vdh3abv-pub.cnc.bj.baidubce.com/paddlex/paddlex:paddlex3.1.2-paddlepaddle3.0.0-gpu-cuda12.6-cudnn9.5-trt10.5 AS gpu-cuda12.6 |
| 18 | + |
| 19 | +# Select the appropriate base image |
| 20 | +FROM gpu-${CUDA_VERSION} AS base |
| 21 | + |
| 22 | +ARG TEST_ENV |
| 23 | + |
| 24 | +WORKDIR /app |
| 25 | + |
| 26 | +ENV PYTHONUNBUFFERED=1 \ |
| 27 | + PYTHONDONTWRITEBYTECODE=1 \ |
| 28 | + PORT=9090 \ |
| 29 | + PIP_CACHE_DIR=/.cache \ |
| 30 | + WORKERS=1 \ |
| 31 | + THREADS=8 |
| 32 | + |
| 33 | +# Install base requirements (label-studio-ml and gunicorn) |
| 34 | +COPY requirements-base.txt . |
| 35 | +RUN --mount=type=cache,target=${PIP_CACHE_DIR},sharing=locked \ |
| 36 | + pip install -r requirements-base.txt |
| 37 | + |
| 38 | +# Install PaddleX OCR extra dependencies |
| 39 | +RUN --mount=type=cache,target=${PIP_CACHE_DIR},sharing=locked \ |
| 40 | + pip install "paddlex[ocr]" |
| 41 | + |
| 42 | +# Install custom requirements (boto3, opencv, etc.) |
| 43 | +COPY requirements.txt . |
| 44 | +RUN --mount=type=cache,target=${PIP_CACHE_DIR},sharing=locked \ |
| 45 | + pip install -r requirements.txt |
| 46 | + |
| 47 | +# Install test requirements if needed |
| 48 | +COPY requirements-test.txt . |
| 49 | +RUN --mount=type=cache,target=${PIP_CACHE_DIR},sharing=locked \ |
| 50 | + if [ "$TEST_ENV" = "true" ]; then \ |
| 51 | + pip install -r requirements-test.txt; \ |
| 52 | + fi |
| 53 | + |
| 54 | +# Copy application code |
| 55 | +COPY . . |
| 56 | + |
| 57 | +EXPOSE 9090 |
| 58 | + |
| 59 | +CMD gunicorn --preload --bind :$PORT --workers $WORKERS --threads $THREADS --timeout 0 _wsgi:app |
0 commit comments