versa / Dockerfile
ftshijt
update the process with permission
9cdf2c6
raw
history blame
2.12 kB
FROM python:3.9-slim
# Install system dependencies
RUN apt-get update && apt-get install -y \
git \
build-essential \
libsndfile1 \
ffmpeg \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
# Set for Numba cache (error from https://github.com/librosa/librosa/issues/1156)
RUN mkdir -m 777 /tmp/NUMBA_CACHE_DIR /tmp/MPLCONFIGDIR
ENV NUMBA_CACHE_DIR=/tmp/NUMBA_CACHE_DIR/
ENV MPLCONFIGDIR=/tmp/MPLCONFIGDIR/
# Set up a new user named "user" with user ID 1000
RUN useradd -m -u 1000 user
# Switch to the "user" user
USER user
# Set home to the user's home directory
ENV HOME=/home/user
ENV PATH=/home/user/.local/bin:$PATH
WORKDIR $HOME/app
# Copy requirements file
COPY --chown=user requirements.txt .
# Install Python dependencies
RUN pip install --no-cache-dir -U pip && \
pip install --no-cache-dir -r requirements.txt
# Clone VERSA repository
RUN git clone https://github.com/wavlab-speech/versa.git && \
cd versa && \
pip install -e .
# Create directories with permissive permissions
RUN mkdir -p $HOME/app/.cache \
&& mkdir -p $HOME/app/.cache/huggingface \
&& mkdir -p $HOME/app/.cache/huggingface/token \
mkdir -p $HOME/app/data/configs $HOME/app/data/uploads $HOME/app/data/results
# Copy universal metrics YAML file
COPY --chown=user universal_metrics.yaml $HOME/app/data/configs/
# Copy application code
COPY --chown=user app.py .
# Create installation complete indicator
RUN touch $HOME/app/versa/.installation_complete
# Set port
EXPOSE 7860
# Set environment variables
ENV GRADIO_SERVER_NAME="0.0.0.0"
ENV NLTK_DATA=$HOME/local/share/nltk_data
ENV PYTHONUNBUFFERED=1
ENV HF_HOME=$HOME/.cache/huggingface
# Disable token verification for huggingface models
ENV TRANSFORMERS_OFFLINE=1
ENV HF_DATASETS_OFFLINE=1
# Prevent huggingface from trying to access token
ENV HF_HUB_OFFLINE=1
# Pre-download NLTK data
RUN python -c "import nltk; nltk.download('punkt', download_dir='$NLTK_DATA'); nltk.download('stopwords', download_dir='$NLTK_DATA'); nltk.download('wordnet', download_dir='$NLTK_DATA')"
# Run the application
CMD ["python", "app.py"]