# Base: nvidia/cuda:12.3.1-devel-ubuntu22.04 FROM nvidia/cuda:12.3.1-devel-ubuntu22.04 # Install system dependencies with explicit OpenGL libraries RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y \ git-lfs \ wget \ libgl1 \ libglib2.0-0 \ && apt-get clean \ && rm -rf /var/lib/apt/lists/* \ && git lfs install # Install Miniconda for Python 3.12 RUN wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh -O miniconda.sh && \ bash miniconda.sh -b -p /opt/conda && \ rm miniconda.sh ENV PATH="/opt/conda/bin:$PATH" # Create and activate Conda environment with Python 3.12, and set it as the default RUN conda create -n omni python=3.12 && \ echo "source activate omni" > ~/.bashrc ENV CONDA_DEFAULT_ENV=omni ENV PATH="/opt/conda/envs/omni/bin:$PATH" # Set a writable directory for EasyOCR ENV HOME=/usr/src/app # Set the working directory in the container WORKDIR /usr/src/app RUN chown -R 1000:1000 /usr/src/app # Create EasyOCR writable directory RUN mkdir -p /usr/src/app/.EasyOCR && chown -R 1000:1000 /usr/src/app/.EasyOCR # Copy project files and requirements COPY . . COPY requirements.txt /usr/src/app/requirements.txt # Initialize Git LFS and pull LFS files # RUN git lfs install && \ # git lfs pull # Install dependencies from requirements.txt with specific opencv-python-headless version RUN . /opt/conda/etc/profile.d/conda.sh && conda activate omni && \ pip uninstall -y opencv-python opencv-python-headless && \ pip install --no-cache-dir opencv-python-headless==4.8.1.78 && \ pip install -r requirements.txt && \ pip install huggingface_hub # # Run download.py to fetch model weights and convert safetensors to .pt format # RUN . /opt/conda/etc/profile.d/conda.sh && conda activate omni && \ # python download.py && \ # echo "Contents of weights directory:" && \ # ls -lR weights && \ # python weights/convert_safetensor_to_pt.py # Expose the port for the FastAPI app EXPOSE 7860 # Set the entry point for the FastAPI app CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]