Dockerfile_conda
1 # Build an image that can serve mlflow models. 2 FROM ubuntu:22.04 3 4 RUN apt-get -y update && DEBIAN_FRONTEND=noninteractive TZ=Etc/UTC apt-get install -y --no-install-recommends wget curl nginx ca-certificates bzip2 build-essential cmake git-core 5 6 # Setup miniconda 7 RUN curl --fail -L https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh > miniconda.sh 8 RUN bash ./miniconda.sh -b -p /miniconda && rm ./miniconda.sh 9 ENV PATH="/miniconda/bin:$PATH" 10 # Remove default channels to avoid `CondaToSNonInteractiveError`. 11 # See https://github.com/mlflow/mlflow/pull/16752 for more details. 12 RUN conda config --system --remove channels defaults && conda config --system --add channels conda-forge 13 14 15 # Setup Java 16 RUN apt-get install -y --no-install-recommends openjdk-17-jdk maven 17 ENV JAVA_HOME=/usr/lib/jvm/java-17-openjdk-amd64 18 19 WORKDIR /opt/mlflow 20 21 # Install MLflow 22 RUN pip install ${{ MLFLOW_INSTALL }} 23 24 # Copy model to image and install dependencies 25 COPY model_dir/model /opt/ml/model 26 RUN python -c "from mlflow.models import container as C; C._install_pyfunc_deps('/opt/ml/model', install_mlflow=False, enable_mlserver=False, env_manager='conda');" 27 28 ENV MLFLOW_DISABLE_ENV_CREATION=True 29 ENV ENABLE_MLSERVER=False 30 31 # granting read/write access and conditional execution authority to all child directories 32 # and files to allow for deployment to AWS Sagemaker Serverless Endpoints 33 # (see https://docs.aws.amazon.com/sagemaker/latest/dg/serverless-endpoints.html) 34 RUN chmod o+rwX /opt/mlflow/ 35 36 # clean up apt cache to reduce image size 37 RUN rm -rf /var/lib/apt/lists/* 38 39 ENTRYPOINT ["python", "-c", "from mlflow.models import container as C; C._serve('conda')"]