Spaces:
Sleeping
Sleeping
# Use a base image with Conda installed | |
FROM centos:7 | |
FROM python:3.9.18 | |
FROM continuumio/miniconda3:latest | |
WORKDIR /app | |
COPY *requirements.txt /app/ | |
# Clone the RoLASER repository into the container | |
RUN apt-get update && \ | |
apt-get install -y g++ && \ | |
apt-get install -y unzip && \ | |
apt-get install -y git && \ | |
git clone https://github.com/lydianish/RoLASER.git /app/RoLASER | |
# Create conda environment with the required Python and GCC versions | |
WORKDIR /app/RoLASER | |
COPY environment.yml /app/RoLASER/environment.yml | |
RUN conda env create -f environment.yml | |
RUN echo "conda activate rolaser_env" >> ~/.bashrc | |
ENV PATH /opt/conda/envs/rolaser_env/bin:$PATH | |
ENV ROLASER /app/RoLASER | |
# Install PyTorch 1.10.1 | |
RUN pip3 install --no-cache-dir torch==1.10.1 torchvision==0.11.2 torchaudio==0.10.1 -f https://download.pytorch.org/whl/cu102/torch_stable.html | |
# Install Fairseq and dependencies | |
RUN git clone https://github.com/lydianish/fairseq.git /app/fairseq | |
WORKDIR /app/fairseq | |
RUN git checkout rolaser | |
RUN pip3 install --no-cache-dir --editable . | |
RUN python3 setup.py build_ext --inplace | |
RUN pip3 install --no-cache-dir -r /app/FAIRSEQ_requirements.txt | |
ENV FAIRSEQ /app/fairseq | |
# Install LASER and dependencies | |
RUN git clone https://github.com/lydianish/LASER.git /app/LASER | |
WORKDIR /app/LASER | |
RUN git checkout rolaser | |
ENV LASER /app/LASER | |
RUN bash ./install_external_tools.sh | |
RUN pip3 install --no-cache-dir -r /app/LASER_requirements.txt | |
# Install other RoLASER dependencies | |
WORKDIR /app/RoLASER | |
RUN pip3 install --no-cache-dir -r /app/ROLASER_requirements.txt | |
# Download models | |
WORKDIR /app/RoLASER/models | |
RUN wget https://zenodo.org/api/records/10864557/files-archive | |
RUN unzip files-archive | |
RUN mkdir $LASER/models \ | |
&& mv laser* $LASER/models \ | |
&& mkdir RoLASER \ | |
&& mv rolaser* RoLASER/ \ | |
&& mkdir c-RoLASER \ | |
&& mv c-rolaser* c-RoLASER/ \ | |
&& rm files-archive | |
# Set Python system path to find the Fairseq and LASER modules | |
ENV PYTHONPATH $PYTHONPATH:$FAIRSEQ | |
ENV PYTHONPATH $PYTHONPATH:$LASER/source | |
# 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/.local/bin:$PATH | |
WORKDIR $HOME | |
RUN mkdir app | |
# Set the working directory to the user's home directory | |
WORKDIR $HOME/app | |
# Copy the current directory contents into the container at $HOME/app setting the owner to the user | |
COPY --chown=user . $HOME/app | |
EXPOSE 7860 | |
CMD streamlit run app.py \ | |
--server.headless true \ | |
--server.enableCORS false \ | |
--server.enableXsrfProtection false \ | |
--server.fileWatcherType none |