Spaces:
Sleeping
Sleeping
Update: v1.9
Browse files- Dockerfile +15 -14
Dockerfile
CHANGED
|
@@ -13,30 +13,36 @@ RUN apt-get update && apt-get install -y git git-lfs && rm -rf /var/lib/apt/list
|
|
| 13 |
RUN useradd -m -u 1000 user
|
| 14 |
WORKDIR /home/user/app
|
| 15 |
|
| 16 |
-
# Create necessary directories
|
| 17 |
-
RUN mkdir -p /home/user/model /home/user/data
|
|
|
|
| 18 |
|
| 19 |
# Set environment variables
|
| 20 |
ENV HF_ENDPOINT=https://hf-mirror.com
|
| 21 |
ENV PATH="/home/user/.local/bin:$PATH"
|
| 22 |
ENV PYTHONPATH="/home/user/app:$PYTHONPATH"
|
|
|
|
|
|
|
|
|
|
|
|
|
| 23 |
|
| 24 |
# Copy requirements first
|
| 25 |
COPY --chown=user requirements.txt .
|
| 26 |
|
| 27 |
-
# Install Python dependencies
|
| 28 |
RUN pip install --no-cache-dir -r requirements.txt && \
|
| 29 |
pip install --no-cache-dir transformers torch sentence-transformers streamlit
|
| 30 |
|
| 31 |
-
# Download
|
| 32 |
RUN cd /home/user/model && \
|
| 33 |
git clone https://www.modelscope.cn/Ceceliachenen/paraphrase-multilingual-MiniLM-L12-v2.git && \
|
| 34 |
cd /home/user/model/paraphrase-multilingual-MiniLM-L12-v2 && \
|
| 35 |
git lfs install && \
|
| 36 |
git lfs pull
|
| 37 |
|
| 38 |
-
#
|
| 39 |
-
RUN
|
|
|
|
| 40 |
git clone https://gitee.com/yzy0612/nltk_data.git --branch gh-pages && \
|
| 41 |
cd /home/user/nltk_data && \
|
| 42 |
mv /home/user/nltk_data/packages/* /home/user/nltk_data && \
|
|
@@ -46,21 +52,16 @@ RUN cd /home/user && \
|
|
| 46 |
unzip averaged_perceptron_tagger.zip
|
| 47 |
|
| 48 |
# Download demo data
|
| 49 |
-
RUN
|
|
|
|
| 50 |
git clone https://github.com/Kit-Hung/demos && \
|
| 51 |
cp /home/user/data/demos/k8s/1-deploy/3-k8s_install/2-kubeadm/kubeadm.md /home/user/data
|
| 52 |
|
| 53 |
# Copy application files
|
| 54 |
COPY --chown=user . .
|
| 55 |
|
| 56 |
-
# Change ownership of all files to user
|
| 57 |
-
RUN chown -R user:user /home/user
|
| 58 |
-
|
| 59 |
-
# Switch to non-root user
|
| 60 |
-
USER user
|
| 61 |
-
|
| 62 |
# Expose Streamlit port
|
| 63 |
EXPOSE 8501
|
| 64 |
|
| 65 |
-
# Run streamlit
|
| 66 |
CMD ["streamlit", "run", "app.py"]
|
|
|
|
| 13 |
RUN useradd -m -u 1000 user
|
| 14 |
WORKDIR /home/user/app
|
| 15 |
|
| 16 |
+
# Create necessary directories and set permissions
|
| 17 |
+
RUN mkdir -p /home/user/model /home/user/data /home/user/.cache /usr/local/lib/python3.10/site-packages/nltk_data && \
|
| 18 |
+
chown -R user:user /home/user /usr/local/lib/python3.10/site-packages/nltk_data
|
| 19 |
|
| 20 |
# Set environment variables
|
| 21 |
ENV HF_ENDPOINT=https://hf-mirror.com
|
| 22 |
ENV PATH="/home/user/.local/bin:$PATH"
|
| 23 |
ENV PYTHONPATH="/home/user/app:$PYTHONPATH"
|
| 24 |
+
ENV NLTK_DATA="/home/user/nltk_data"
|
| 25 |
+
|
| 26 |
+
# Switch to user for pip installations
|
| 27 |
+
USER user
|
| 28 |
|
| 29 |
# Copy requirements first
|
| 30 |
COPY --chown=user requirements.txt .
|
| 31 |
|
| 32 |
+
# Install Python dependencies
|
| 33 |
RUN pip install --no-cache-dir -r requirements.txt && \
|
| 34 |
pip install --no-cache-dir transformers torch sentence-transformers streamlit
|
| 35 |
|
| 36 |
+
# Download models and data
|
| 37 |
RUN cd /home/user/model && \
|
| 38 |
git clone https://www.modelscope.cn/Ceceliachenen/paraphrase-multilingual-MiniLM-L12-v2.git && \
|
| 39 |
cd /home/user/model/paraphrase-multilingual-MiniLM-L12-v2 && \
|
| 40 |
git lfs install && \
|
| 41 |
git lfs pull
|
| 42 |
|
| 43 |
+
# Create NLTK data directory and download data
|
| 44 |
+
RUN mkdir -p /home/user/nltk_data && \
|
| 45 |
+
cd /home/user && \
|
| 46 |
git clone https://gitee.com/yzy0612/nltk_data.git --branch gh-pages && \
|
| 47 |
cd /home/user/nltk_data && \
|
| 48 |
mv /home/user/nltk_data/packages/* /home/user/nltk_data && \
|
|
|
|
| 52 |
unzip averaged_perceptron_tagger.zip
|
| 53 |
|
| 54 |
# Download demo data
|
| 55 |
+
RUN mkdir -p /home/user/data && \
|
| 56 |
+
cd /home/user/data && \
|
| 57 |
git clone https://github.com/Kit-Hung/demos && \
|
| 58 |
cp /home/user/data/demos/k8s/1-deploy/3-k8s_install/2-kubeadm/kubeadm.md /home/user/data
|
| 59 |
|
| 60 |
# Copy application files
|
| 61 |
COPY --chown=user . .
|
| 62 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 63 |
# Expose Streamlit port
|
| 64 |
EXPOSE 8501
|
| 65 |
|
| 66 |
+
# Run streamlit
|
| 67 |
CMD ["streamlit", "run", "app.py"]
|