testingnewcode / Dockerfile
sksameermujahid's picture
Update Dockerfile
e341d1c verified
FROM python:3.11-slim
WORKDIR /code
# Create cache directory and set permissions
RUN mkdir -p /cache && \
chmod 777 /cache && \
mkdir -p /.cache && \
chmod 777 /.cache
# Set cache environment variables
ENV TRANSFORMERS_CACHE=/cache \
HF_HOME=/cache \
XDG_CACHE_HOME=/cache \
PYTHONPATH=/code \
TORCH_HOME=/cache \
BNB_CUDA_VERSION=0
# Install system dependencies
RUN apt-get update && apt-get install -y \
gcc \
g++ \
make \
git \
ffmpeg \
libsndfile1 \
portaudio19-dev \
python3-dev \
build-essential \
&& rm -rf /var/lib/apt/lists/*
# Copy requirements first to leverage Docker cache
COPY ./requirements.txt /code/requirements.txt
# Install Python packages in multiple steps to handle dependencies better
RUN pip install --no-cache-dir --upgrade pip && \
pip install --no-cache-dir 'numpy==1.23.5' && \
pip install --no-cache-dir 'scikit-learn==1.6.1' && \
pip install --no-cache-dir 'faiss-cpu==1.7.3' && \
pip install --no-cache-dir einops>=0.6.1 && \
pip install --no-cache-dir -U bitsandbytes>=0.42.0 && \
pip install --no-cache-dir -r /code/requirements.txt
# Copy the rest of the application
COPY ./app.py /code/app.py
COPY ./templates /code/templates
COPY ./models /code/models
# Set proper permissions for the application
RUN chown -R 1000:1000 /code && \
chmod -R 755 /code && \
chmod -R 777 /cache
EXPOSE 7860
# Create and switch to non-root user
RUN useradd -m -u 1000 user
USER user
CMD ["python", "app.py"]