Spaces:
Sleeping
Sleeping
# Use an official Python runtime as a parent image | |
FROM nvidia/cuda:12.3.1-runtime-ubuntu22.04 | |
# Set Python to use unbuffered mode | |
ENV PYTHONUNBUFFERED=1 | |
ENV PATH="/var/www/.local/bin:${PATH}" | |
# Create a non-root user | |
RUN useradd -m -u 1000 -U -s /bin/bash myuser | |
# Install dependencies | |
RUN apt-get update && \ | |
apt-get install -y --no-install-recommends python3-pip python3-dev && \ | |
rm -rf /var/lib/apt/lists/* | |
# Set the working directory in the container | |
RUN mkdir /var/www | |
ENV HOME=/var/www | |
WORKDIR /var/www | |
# Change ownership of /var/www to the non-root user | |
RUN chown -R myuser:myuser /var/www | |
# Switch to the non-root user | |
USER myuser | |
# Copy the current directory contents into the container at /var/www | |
COPY . /var/www | |
# Install Python dependencies | |
RUN pip install --user -r requirements.txt | |
# RUN pip install --user torch==1.12.1+cu113 -f https://download.pytorch.org/whl/cu113/torch_stable.html | |
# RUN pip install --user ../whl/semantic_search_multistep_data/whl/torch-1.12.1+cu113-cp310-cp310-linux_x86_64.whl | |
# Expose the port | |
EXPOSE 7860 | |
RUN mkdir /var/www/logs | |
# Set environment variables | |
ENV MODEL_PATH="BAAI/bge-m3" \ | |
DEVICE="gpu" | |
# Run fastapi_app.py when the container launches | |
CMD python3 -m uvicorn search_api:app --host=0.0.0.0 --port=7860 |