self-trained2 / Dockerfile
DeepImagix's picture
Update Dockerfile
b5d454f verified
raw
history blame
1.11 kB
# Start with a standard, lightweight Python base image
FROM python:3.10-slim
# Set the working directory
WORKDIR /code
# Create persistent data directory and huggingface cache directory
RUN mkdir -p /data/user_models_data \
&& mkdir -p /data/huggingface_cache \
&& chmod -R 777 /data
# Set environment variables for Hugging Face cache
ENV HF_HOME=/data/huggingface_cache
ENV TRANSFORMERS_CACHE=/data/huggingface_cache
ENV TORCH_HOME=/data/huggingface_cache
# Volume to make learned data persistent
VOLUME /data/user_models_data
# Copy requirements and app code
COPY ./requirements.txt /code/requirements.txt
COPY ./user_models_data /data/user_models_data
COPY ./main.py /code/main.py
# Install dependencies
RUN pip install --upgrade pip
RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt
# Pre-download the sentence-transformers model
RUN python -c "from sentence_transformers import SentenceTransformer; SentenceTransformer('all-MiniLM-L6-v2')"
# Expose the port used by Uvicorn
EXPOSE 7860
# Start the app
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]