Spaces:
Sleeping
Sleeping
# Set up base image (use the correct Hugging Face registry) | |
FROM registry.huggingface.co/microsoft-omniparser:latest | |
# Set environment variables for authentication (persist across layers) | |
ARG HF_TOKEN | |
ARG HF_USERNAME | |
ENV HF_TOKEN=${HF_TOKEN} | |
ENV HF_USERNAME=${HF_USERNAME} | |
# Authenticate with Hugging Face's Docker registry | |
RUN echo "$HF_TOKEN" | docker login registry.huggingface.co -u "$HF_USERNAME" --password-stdin | |
# Switch to root user for package installation | |
USER root | |
# Install system dependencies | |
RUN chmod 1777 /tmp \ | |
&& apt update -q && apt install -y ca-certificates wget libgl1 \ | |
&& wget -qO /tmp/cuda-keyring.deb https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2204/x86_64/cuda-keyring_1.1-1_all.deb \ | |
&& dpkg -i /tmp/cuda-keyring.deb && apt update -q \ | |
&& apt install -y --no-install-recommends libcudnn8 libcublas-12-2 | |
# Install required Python packages | |
RUN pip install fastapi[all] | |
# Create the application directory | |
RUN mkdir -p /app | |
WORKDIR /app | |
# Copy application files | |
COPY main.py /app/main.py | |
# Set entry point to run the FastAPI server | |
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"] | |