pytorch, sutime, flash python 自定义镜像(基于slim)

FROM python:3.9-slim as sutime-jar

RUN mkdir -p /usr/lib/jvm && mkdir /opt/java-1.8-openjdk && mkdir /opt/maven-3.6.3

RUN apt-get update && apt-get -y install wget

RUN wget https://archive.apache.org/dist/maven/maven-3/3.6.3/binaries/apache-maven-3.6.3-bin.tar.gz -O apache-maven-3.6.3-bin.tar.gz && \
    tar -zxvf apache-maven-3.6.3-bin.tar.gz --strip 1 -C /opt/maven-3.6.3 && \
    rm -rf apache-maven-3.6.3-bin.tar.gz

RUN wget https://builds.openlogic.com/downloadJDK/openlogic-openjdk/8u292-b10/openlogic-openjdk-8u292-b10-linux-x64.tar.gz -O java-1.8-openjdk.tar.gz && \
    tar -zxvf java-1.8-openjdk.tar.gz --strip 1 -C /opt/java-1.8-openjdk && \
    rm -rf java-1.8-openjdk.tar.gz

RUN ln -s /opt/java-1.8-openjdk /usr/lib/jvm/java-1.8-openjdk

ENV JAVA_HOME /usr/lib/jvm/java-1.8-openjdk

ENV MAVEN_HOME /opt/maven-3.6.3

ENV PATH $PATH:$MAVEN_HOME/bin:$JAVA_HOME/bin


RUN python -m pip install --upgrade pip && \
    pip install sutime && \
    cp /usr/local/lib/python3.9/site-packages/sutime/pom.xml . && \
    mkdir jars && \
    mvn -T 4 dependency:copy-dependencies -DoutputDirectory=./jars && \
    mv ./jars/* /usr/local/lib/python3.9/site-packages/sutime/jars


FROM python:3.9-slim as builder

RUN apt-get update && \
    apt-get -y install gnupg2 && \
    apt-get -y install software-properties-common && \
    apt-key adv --fetch-keys https://developer.download.nvidia.com/compute/cuda/repos/debian11/x86_64/7fa2af80.pub && \
    add-apt-repository "deb https://developer.download.nvidia.com/compute/cuda/repos/debian11/x86_64/ /" && \
    add-apt-repository contrib && \
    apt-get update && \
    apt-get -y install cuda && \
    apt-get -y install gcc

RUN python -m pip install --upgrade pip && \
    pip install torch==1.10.2+cpu -f https://download.pytorch.org/whl/cpu/torch_stable.html && \
    pip install Flask Requests uwsgi sutime python-dateutil nltk vaderSentiment transformers && \
    python -c "import nltk; nltk.download('vader_lexicon');" && \
    python -c "from transformers import pipeline; classifier = pipeline('sentiment-analysis', model='severo/autonlp-sentiment_detection-1781580', use_fast=False);"

COPY --from=sutime-jar /opt/java-1.8-openjdk/jre /opt/jre-8u292-b10

COPY --from=sutime-jar /usr/local/lib/python3.9/site-packages/sutime/jars /usr/local/lib/python3.9/site-packages/sutime/jars

RUN mkdir -p /usr/local/java && ln -s /opt/jre-8u292-b10 /usr/local/java/jre-8u292-b10

RUN update-alternatives --install "/usr/bin/java" "java" "/usr/local/java/jre-8u292-b10/bin/java" 1
posted @ 2022-02-07 15:40  cc-31415926  阅读(130)  评论(0编辑  收藏  举报