We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
[BUG] `pip: not found` on `mlflow models build-docker`
Thank you for submitting an issue. Please refer to our [issue policy](https://www.github.com/mlflow/mlflow/blob/master/ISSUE_POLICY.md)
for information on what types of issues we address. For help with debugging your code, please refer to [Stack Overflow](https://stackoverflow.com/questions/tagged/mlflow).

Please fill in this template and do not delete it unless you are sure your issue is outside its scope.

### System information
- **Have I written custom code (as opposed to using a stock example script provided in MLflow)**: no
- **OS Platform and Distribution (e.g., Linux Ubuntu 16.04)**: Macos/Alpine
- **MLflow installed from (source or binary)**: source
- **MLflow version (run ``mlflow --version``)**: 1.7.2
- **Python version**: 3.7.0
- **npm version, if running the dev UI**: no
- **Exact command to reproduce**: mlflow models build-docker -m runs:/{run_id}/model -n test:test

### Describe the problem
Describe the problem clearly here. Include descriptions of the expected behavior and the actual behavior.

From today building docker image stoped to work with this command `/bin/sh: 1: pip: not found`

### Code to reproduce issue
Provide a reproducible test case that is the bare minimum necessary to generate the problem.

Delete docker image cache and run specified above command. 

### Other info / logs
Include any logs or source code that would be helpful to diagnose the problem. If including tracebacks,
please include the full traceback. Large logs and files should be attached.

Building docker image for run: 11b73737169841fb867916b8788ce111
2020/04/12 21:18:07 INFO mlflow.models.cli: Selected backend for flavor 'python_function'
2020/04/12 21:18:24 INFO mlflow.models.docker_utils: Building docker image with name mlflow-image-vectors:latest
/var/folders/m1/xp7nclf15g5cw_ty2b7n4fb80000gn/T/tmplxi4s8jl/
/var/folders/m1/xp7nclf15g5cw_ty2b7n4fb80000gn/T/tmplxi4s8jl//model_dir
/var/folders/m1/xp7nclf15g5cw_ty2b7n4fb80000gn/T/tmplxi4s8jl//model_dir/model
/var/folders/m1/xp7nclf15g5cw_ty2b7n4fb80000gn/T/tmplxi4s8jl//model_dir/model/MLmodel
/var/folders/m1/xp7nclf15g5cw_ty2b7n4fb80000gn/T/tmplxi4s8jl//model_dir/model/code
/var/folders/m1/xp7nclf15g5cw_ty2b7n4fb80000gn/T/tmplxi4s8jl//model_dir/model/code/mlflow_utils
/var/folders/m1/xp7nclf15g5cw_ty2b7n4fb80000gn/T/tmplxi4s8jl//model_dir/model/code/mlflow_utils/Dockerfile
/var/folders/m1/xp7nclf15g5cw_ty2b7n4fb80000gn/T/tmplxi4s8jl//model_dir/model/code/mlflow_utils/mlflow_model.py
/var/folders/m1/xp7nclf15g5cw_ty2b7n4fb80000gn/T/tmplxi4s8jl//model_dir/model/code/mlflow_utils/__init__.py
/var/folders/m1/xp7nclf15g5cw_ty2b7n4fb80000gn/T/tmplxi4s8jl//model_dir/model/code/mlflow_utils/__pycache__
/var/folders/m1/xp7nclf15g5cw_ty2b7n4fb80000gn/T/tmplxi4s8jl//model_dir/model/code/mlflow_utils/__pycache__/mlflow_model.cpython-37.pyc
/var/folders/m1/xp7nclf15g5cw_ty2b7n4fb80000gn/T/tmplxi4s8jl//model_dir/model/code/mlflow_utils/__pycache__/__init__.cpython-37.pyc
/var/folders/m1/xp7nclf15g5cw_ty2b7n4fb80000gn/T/tmplxi4s8jl//model_dir/model/code/mlflow_image_vectors
/var/folders/m1/xp7nclf15g5cw_ty2b7n4fb80000gn/T/tmplxi4s8jl//model_dir/model/code/mlflow_image_vectors/__init__.py
/var/folders/m1/xp7nclf15g5cw_ty2b7n4fb80000gn/T/tmplxi4s8jl//model_dir/model/code/mlflow_image_vectors/models
/var/folders/m1/xp7nclf15g5cw_ty2b7n4fb80000gn/T/tmplxi4s8jl//model_dir/model/code/mlflow_image_vectors/models/__init__.py
/var/folders/m1/xp7nclf15g5cw_ty2b7n4fb80000gn/T/tmplxi4s8jl//model_dir/model/code/mlflow_image_vectors/models/__pycache__
/var/folders/m1/xp7nclf15g5cw_ty2b7n4fb80000gn/T/tmplxi4s8jl//model_dir/model/code/mlflow_image_vectors/models/__pycache__/keras_inception_v3_u128.cpython-37.pyc
/var/folders/m1/xp7nclf15g5cw_ty2b7n4fb80000gn/T/tmplxi4s8jl//model_dir/model/code/mlflow_image_vectors/models/__pycache__/__init__.cpython-37.pyc
/var/folders/m1/xp7nclf15g5cw_ty2b7n4fb80000gn/T/tmplxi4s8jl//model_dir/model/code/mlflow_image_vectors/models/keras_inception_v3_u128.py
/var/folders/m1/xp7nclf15g5cw_ty2b7n4fb80000gn/T/tmplxi4s8jl//model_dir/model/code/mlflow_image_vectors/__pycache__
/var/folders/m1/xp7nclf15g5cw_ty2b7n4fb80000gn/T/tmplxi4s8jl//model_dir/model/code/mlflow_image_vectors/__pycache__/__init__.cpython-37.pyc
/var/folders/m1/xp7nclf15g5cw_ty2b7n4fb80000gn/T/tmplxi4s8jl//model_dir/model/python_model.pkl
/var/folders/m1/xp7nclf15g5cw_ty2b7n4fb80000gn/T/tmplxi4s8jl//model_dir/model/conda.yaml
/var/folders/m1/xp7nclf15g5cw_ty2b7n4fb80000gn/T/tmplxi4s8jl//Dockerfile
Sending build context to Docker daemon  35.33kB

Step 1/17 : FROM ubuntu:18.04
 ---> 4e5021d210f6
Step 2/17 : RUN apt-get -y update && apt-get install -y --no-install-recommends          wget          curl          nginx          ca-certificates          bzip2          build-essential          cmake          openjdk-8-jdk          git-core          maven     && rm -rf /var/lib/apt/lists/*
 ---> Using cache
 ---> 3e1b0ec18fb3
Step 3/17 : RUN curl https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh >> miniconda.sh
 ---> Using cache
 ---> b4b068e2d493
Step 4/17 : RUN bash ./miniconda.sh -b -p /miniconda; rm ./miniconda.sh;
 ---> Using cache
 ---> 52f146aa012c
Step 5/17 : ENV PATH="/miniconda/bin:$PATH"
 ---> Using cache
 ---> 6e7758289f76
Step 6/17 : ENV JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64
 ---> Using cache
 ---> 20e01d0c1b79
Step 7/17 : ENV GUNICORN_CMD_ARGS="--timeout 60 -k gevent"
 ---> Using cache
 ---> 8d9d20195e8e
Step 8/17 : WORKDIR /opt/mlflow
 ---> Using cache
 ---> 51d39c46e3bc
Step 9/17 : RUN pip install mlflow==1.7.2
 ---> Running in b69369bccce1
/bin/sh: 1: pip: not found
The command '/bin/sh -c pip install mlflow==1.7.2' returned a non-zero code: 127

--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `mlflow/models/docker_utils.py`
Content:
```
1 import os
2 from subprocess import Popen, PIPE, STDOUT
3 import logging
4 
5 import mlflow
6 import mlflow.version
7 from mlflow.utils.file_utils import TempDir, _copy_project
8 from mlflow.utils.logging_utils import eprint
9 
10 _logger = logging.getLogger(__name__)
11 
12 DISABLE_ENV_CREATION = "MLFLOW_DISABLE_ENV_CREATION"
13 
14 _DOCKERFILE_TEMPLATE = """
15 # Build an image that can serve mlflow models.
16 FROM ubuntu:18.04
17 
18 RUN apt-get -y update && apt-get install -y --no-install-recommends \
19          wget \
20          curl \
21          nginx \
22          ca-certificates \
23          bzip2 \
24          build-essential \
25          cmake \
26          openjdk-8-jdk \
27          git-core \
28          maven \
29     && rm -rf /var/lib/apt/lists/*
30 
31 # Download and setup miniconda
32 RUN curl https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh >> miniconda.sh
33 RUN bash ./miniconda.sh -b -p /miniconda; rm ./miniconda.sh;
34 ENV PATH="/miniconda/bin:$PATH"
35 ENV JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64
36 ENV GUNICORN_CMD_ARGS="--timeout 60 -k gevent"
37 # Set up the program in the image
38 WORKDIR /opt/mlflow
39 
40 {install_mlflow}
41 
42 {custom_setup_steps}
43 {entrypoint}
44 """
45 
46 
47 def _get_mlflow_install_step(dockerfile_context_dir, mlflow_home):
48     """
49     Get docker build commands for installing MLflow given a Docker context dir and optional source
50     directory
51     """
52     if mlflow_home:
53         mlflow_dir = _copy_project(
54             src_path=mlflow_home, dst_path=dockerfile_context_dir)
55         return (
56             "COPY {mlflow_dir} /opt/mlflow\n"
57             "RUN pip install /opt/mlflow\n"
58             "RUN cd /opt/mlflow/mlflow/java/scoring && "
59             "mvn --batch-mode package -DskipTests && "
60             "mkdir -p /opt/java/jars && "
61             "mv /opt/mlflow/mlflow/java/scoring/target/"
62             "mlflow-scoring-*-with-dependencies.jar /opt/java/jars\n"
63         ).format(mlflow_dir=mlflow_dir)
64     else:
65         return (
66             "RUN pip install mlflow=={version}\n"
67             "RUN mvn "
68             " --batch-mode dependency:copy"
69             " -Dartifact=org.mlflow:mlflow-scoring:{version}:pom"
70             " -DoutputDirectory=/opt/java\n"
71             "RUN mvn "
72             " --batch-mode dependency:copy"
73             " -Dartifact=org.mlflow:mlflow-scoring:{version}:jar"
74             " -DoutputDirectory=/opt/java/jars\n"
75             "RUN cp /opt/java/mlflow-scoring-{version}.pom /opt/java/pom.xml\n"
76             "RUN cd /opt/java && mvn "
77             "--batch-mode dependency:copy-dependencies -DoutputDirectory=/opt/java/jars\n"
78         ).format(version=mlflow.version.VERSION)
79 
80 
81 def _build_image(image_name, entrypoint, mlflow_home=None, custom_setup_steps_hook=None):
82     """
83     Build an MLflow Docker image that can be used to serve a
84     The image is built locally and it requires Docker to run.
85 
86     :param image_name: Docker image name.
87     :param entry_point: String containing ENTRYPOINT directive for docker image
88     :param mlflow_home: (Optional) Path to a local copy of the MLflow GitHub repository.
89                         If specified, the image will install MLflow from this directory.
90                         If None, it will install MLflow from pip.
91     :param custom_setup_steps_hook: (Optional) Single-argument function that takes the string path
92            of a dockerfile context directory and returns a string containing Dockerfile commands to
93            run during the image build step.
94     """
95     mlflow_home = os.path.abspath(mlflow_home) if mlflow_home else None
96     with TempDir() as tmp:
97         cwd = tmp.path()
98         install_mlflow = _get_mlflow_install_step(cwd, mlflow_home)
99         custom_setup_steps = custom_setup_steps_hook(cwd) if custom_setup_steps_hook else ""
100         with open(os.path.join(cwd, "Dockerfile"), "w") as f:
101             f.write(_DOCKERFILE_TEMPLATE.format(
102                 install_mlflow=install_mlflow, custom_setup_steps=custom_setup_steps,
103                 entrypoint=entrypoint))
104         _logger.info("Building docker image with name %s", image_name)
105         os.system('find {cwd}/'.format(cwd=cwd))
106         proc = Popen(["docker", "build", "-t", image_name, "-f", "Dockerfile", "."],
107                      cwd=cwd,
108                      stdout=PIPE,
109                      stderr=STDOUT,
110                      universal_newlines=True)
111         for x in iter(proc.stdout.readline, ""):
112             eprint(x, end='')
113
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/mlflow/models/docker_utils.py b/mlflow/models/docker_utils.py
--- a/mlflow/models/docker_utils.py
+++ b/mlflow/models/docker_utils.py
@@ -29,7 +29,7 @@
     && rm -rf /var/lib/apt/lists/*
 
 # Download and setup miniconda
-RUN curl https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh >> miniconda.sh
+RUN curl -L https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh >> miniconda.sh
 RUN bash ./miniconda.sh -b -p /miniconda; rm ./miniconda.sh;
 ENV PATH="/miniconda/bin:$PATH"
 ENV JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64

{"golden_diff": "diff --git a/mlflow/models/docker_utils.py b/mlflow/models/docker_utils.py\n--- a/mlflow/models/docker_utils.py\n+++ b/mlflow/models/docker_utils.py\n@@ -29,7 +29,7 @@\n     && rm -rf /var/lib/apt/lists/*\n \n # Download and setup miniconda\n-RUN curl https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh >> miniconda.sh\n+RUN curl -L https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh >> miniconda.sh\n RUN bash ./miniconda.sh -b -p /miniconda; rm ./miniconda.sh;\n ENV PATH=\"/miniconda/bin:$PATH\"\n ENV JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64\n", "issue": "[BUG] `pip: not found` on `mlflow models build-docker`\nThank you for submitting an issue. Please refer to our [issue policy](https://www.github.com/mlflow/mlflow/blob/master/ISSUE_POLICY.md)\r\nfor information on what types of issues we address. For help with debugging your code, please refer to [Stack Overflow](https://stackoverflow.com/questions/tagged/mlflow).\r\n\r\nPlease fill in this template and do not delete it unless you are sure your issue is outside its scope.\r\n\r\n### System information\r\n- **Have I written custom code (as opposed to using a stock example script provided in MLflow)**: no\r\n- **OS Platform and Distribution (e.g., Linux Ubuntu 16.04)**: Macos/Alpine\r\n- **MLflow installed from (source or binary)**: source\r\n- **MLflow version (run ``mlflow --version``)**: 1.7.2\r\n- **Python version**: 3.7.0\r\n- **npm version, if running the dev UI**: no\r\n- **Exact command to reproduce**: mlflow models build-docker -m runs:/{run_id}/model -n test:test\r\n\r\n### Describe the problem\r\nDescribe the problem clearly here. Include descriptions of the expected behavior and the actual behavior.\r\n\r\nFrom today building docker image stoped to work with this command `/bin/sh: 1: pip: not found`\r\n\r\n### Code to reproduce issue\r\nProvide a reproducible test case that is the bare minimum necessary to generate the problem.\r\n\r\nDelete docker image cache and run specified above command. \r\n\r\n### Other info / logs\r\nInclude any logs or source code that would be helpful to diagnose the problem. If including tracebacks,\r\nplease include the full traceback. Large logs and files should be attached.\r\n\r\nBuilding docker image for run: 11b73737169841fb867916b8788ce111\r\n2020/04/12 21:18:07 INFO mlflow.models.cli: Selected backend for flavor 'python_function'\r\n2020/04/12 21:18:24 INFO mlflow.models.docker_utils: Building docker image with name mlflow-image-vectors:latest\r\n/var/folders/m1/xp7nclf15g5cw_ty2b7n4fb80000gn/T/tmplxi4s8jl/\r\n/var/folders/m1/xp7nclf15g5cw_ty2b7n4fb80000gn/T/tmplxi4s8jl//model_dir\r\n/var/folders/m1/xp7nclf15g5cw_ty2b7n4fb80000gn/T/tmplxi4s8jl//model_dir/model\r\n/var/folders/m1/xp7nclf15g5cw_ty2b7n4fb80000gn/T/tmplxi4s8jl//model_dir/model/MLmodel\r\n/var/folders/m1/xp7nclf15g5cw_ty2b7n4fb80000gn/T/tmplxi4s8jl//model_dir/model/code\r\n/var/folders/m1/xp7nclf15g5cw_ty2b7n4fb80000gn/T/tmplxi4s8jl//model_dir/model/code/mlflow_utils\r\n/var/folders/m1/xp7nclf15g5cw_ty2b7n4fb80000gn/T/tmplxi4s8jl//model_dir/model/code/mlflow_utils/Dockerfile\r\n/var/folders/m1/xp7nclf15g5cw_ty2b7n4fb80000gn/T/tmplxi4s8jl//model_dir/model/code/mlflow_utils/mlflow_model.py\r\n/var/folders/m1/xp7nclf15g5cw_ty2b7n4fb80000gn/T/tmplxi4s8jl//model_dir/model/code/mlflow_utils/__init__.py\r\n/var/folders/m1/xp7nclf15g5cw_ty2b7n4fb80000gn/T/tmplxi4s8jl//model_dir/model/code/mlflow_utils/__pycache__\r\n/var/folders/m1/xp7nclf15g5cw_ty2b7n4fb80000gn/T/tmplxi4s8jl//model_dir/model/code/mlflow_utils/__pycache__/mlflow_model.cpython-37.pyc\r\n/var/folders/m1/xp7nclf15g5cw_ty2b7n4fb80000gn/T/tmplxi4s8jl//model_dir/model/code/mlflow_utils/__pycache__/__init__.cpython-37.pyc\r\n/var/folders/m1/xp7nclf15g5cw_ty2b7n4fb80000gn/T/tmplxi4s8jl//model_dir/model/code/mlflow_image_vectors\r\n/var/folders/m1/xp7nclf15g5cw_ty2b7n4fb80000gn/T/tmplxi4s8jl//model_dir/model/code/mlflow_image_vectors/__init__.py\r\n/var/folders/m1/xp7nclf15g5cw_ty2b7n4fb80000gn/T/tmplxi4s8jl//model_dir/model/code/mlflow_image_vectors/models\r\n/var/folders/m1/xp7nclf15g5cw_ty2b7n4fb80000gn/T/tmplxi4s8jl//model_dir/model/code/mlflow_image_vectors/models/__init__.py\r\n/var/folders/m1/xp7nclf15g5cw_ty2b7n4fb80000gn/T/tmplxi4s8jl//model_dir/model/code/mlflow_image_vectors/models/__pycache__\r\n/var/folders/m1/xp7nclf15g5cw_ty2b7n4fb80000gn/T/tmplxi4s8jl//model_dir/model/code/mlflow_image_vectors/models/__pycache__/keras_inception_v3_u128.cpython-37.pyc\r\n/var/folders/m1/xp7nclf15g5cw_ty2b7n4fb80000gn/T/tmplxi4s8jl//model_dir/model/code/mlflow_image_vectors/models/__pycache__/__init__.cpython-37.pyc\r\n/var/folders/m1/xp7nclf15g5cw_ty2b7n4fb80000gn/T/tmplxi4s8jl//model_dir/model/code/mlflow_image_vectors/models/keras_inception_v3_u128.py\r\n/var/folders/m1/xp7nclf15g5cw_ty2b7n4fb80000gn/T/tmplxi4s8jl//model_dir/model/code/mlflow_image_vectors/__pycache__\r\n/var/folders/m1/xp7nclf15g5cw_ty2b7n4fb80000gn/T/tmplxi4s8jl//model_dir/model/code/mlflow_image_vectors/__pycache__/__init__.cpython-37.pyc\r\n/var/folders/m1/xp7nclf15g5cw_ty2b7n4fb80000gn/T/tmplxi4s8jl//model_dir/model/python_model.pkl\r\n/var/folders/m1/xp7nclf15g5cw_ty2b7n4fb80000gn/T/tmplxi4s8jl//model_dir/model/conda.yaml\r\n/var/folders/m1/xp7nclf15g5cw_ty2b7n4fb80000gn/T/tmplxi4s8jl//Dockerfile\r\nSending build context to Docker daemon  35.33kB\r\n\r\nStep 1/17 : FROM ubuntu:18.04\r\n ---> 4e5021d210f6\r\nStep 2/17 : RUN apt-get -y update && apt-get install -y --no-install-recommends          wget          curl          nginx          ca-certificates          bzip2          build-essential          cmake          openjdk-8-jdk          git-core          maven     && rm -rf /var/lib/apt/lists/*\r\n ---> Using cache\r\n ---> 3e1b0ec18fb3\r\nStep 3/17 : RUN curl https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh >> miniconda.sh\r\n ---> Using cache\r\n ---> b4b068e2d493\r\nStep 4/17 : RUN bash ./miniconda.sh -b -p /miniconda; rm ./miniconda.sh;\r\n ---> Using cache\r\n ---> 52f146aa012c\r\nStep 5/17 : ENV PATH=\"/miniconda/bin:$PATH\"\r\n ---> Using cache\r\n ---> 6e7758289f76\r\nStep 6/17 : ENV JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64\r\n ---> Using cache\r\n ---> 20e01d0c1b79\r\nStep 7/17 : ENV GUNICORN_CMD_ARGS=\"--timeout 60 -k gevent\"\r\n ---> Using cache\r\n ---> 8d9d20195e8e\r\nStep 8/17 : WORKDIR /opt/mlflow\r\n ---> Using cache\r\n ---> 51d39c46e3bc\r\nStep 9/17 : RUN pip install mlflow==1.7.2\r\n ---> Running in b69369bccce1\r\n/bin/sh: 1: pip: not found\r\nThe command '/bin/sh -c pip install mlflow==1.7.2' returned a non-zero code: 127\n", "before_files": [{"content": "import os\nfrom subprocess import Popen, PIPE, STDOUT\nimport logging\n\nimport mlflow\nimport mlflow.version\nfrom mlflow.utils.file_utils import TempDir, _copy_project\nfrom mlflow.utils.logging_utils import eprint\n\n_logger = logging.getLogger(__name__)\n\nDISABLE_ENV_CREATION = \"MLFLOW_DISABLE_ENV_CREATION\"\n\n_DOCKERFILE_TEMPLATE = \"\"\"\n# Build an image that can serve mlflow models.\nFROM ubuntu:18.04\n\nRUN apt-get -y update && apt-get install -y --no-install-recommends \\\n         wget \\\n         curl \\\n         nginx \\\n         ca-certificates \\\n         bzip2 \\\n         build-essential \\\n         cmake \\\n         openjdk-8-jdk \\\n         git-core \\\n         maven \\\n    && rm -rf /var/lib/apt/lists/*\n\n# Download and setup miniconda\nRUN curl https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh >> miniconda.sh\nRUN bash ./miniconda.sh -b -p /miniconda; rm ./miniconda.sh;\nENV PATH=\"/miniconda/bin:$PATH\"\nENV JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64\nENV GUNICORN_CMD_ARGS=\"--timeout 60 -k gevent\"\n# Set up the program in the image\nWORKDIR /opt/mlflow\n\n{install_mlflow}\n\n{custom_setup_steps}\n{entrypoint}\n\"\"\"\n\n\ndef _get_mlflow_install_step(dockerfile_context_dir, mlflow_home):\n    \"\"\"\n    Get docker build commands for installing MLflow given a Docker context dir and optional source\n    directory\n    \"\"\"\n    if mlflow_home:\n        mlflow_dir = _copy_project(\n            src_path=mlflow_home, dst_path=dockerfile_context_dir)\n        return (\n            \"COPY {mlflow_dir} /opt/mlflow\\n\"\n            \"RUN pip install /opt/mlflow\\n\"\n            \"RUN cd /opt/mlflow/mlflow/java/scoring && \"\n            \"mvn --batch-mode package -DskipTests && \"\n            \"mkdir -p /opt/java/jars && \"\n            \"mv /opt/mlflow/mlflow/java/scoring/target/\"\n            \"mlflow-scoring-*-with-dependencies.jar /opt/java/jars\\n\"\n        ).format(mlflow_dir=mlflow_dir)\n    else:\n        return (\n            \"RUN pip install mlflow=={version}\\n\"\n            \"RUN mvn \"\n            \" --batch-mode dependency:copy\"\n            \" -Dartifact=org.mlflow:mlflow-scoring:{version}:pom\"\n            \" -DoutputDirectory=/opt/java\\n\"\n            \"RUN mvn \"\n            \" --batch-mode dependency:copy\"\n            \" -Dartifact=org.mlflow:mlflow-scoring:{version}:jar\"\n            \" -DoutputDirectory=/opt/java/jars\\n\"\n            \"RUN cp /opt/java/mlflow-scoring-{version}.pom /opt/java/pom.xml\\n\"\n            \"RUN cd /opt/java && mvn \"\n            \"--batch-mode dependency:copy-dependencies -DoutputDirectory=/opt/java/jars\\n\"\n        ).format(version=mlflow.version.VERSION)\n\n\ndef _build_image(image_name, entrypoint, mlflow_home=None, custom_setup_steps_hook=None):\n    \"\"\"\n    Build an MLflow Docker image that can be used to serve a\n    The image is built locally and it requires Docker to run.\n\n    :param image_name: Docker image name.\n    :param entry_point: String containing ENTRYPOINT directive for docker image\n    :param mlflow_home: (Optional) Path to a local copy of the MLflow GitHub repository.\n                        If specified, the image will install MLflow from this directory.\n                        If None, it will install MLflow from pip.\n    :param custom_setup_steps_hook: (Optional) Single-argument function that takes the string path\n           of a dockerfile context directory and returns a string containing Dockerfile commands to\n           run during the image build step.\n    \"\"\"\n    mlflow_home = os.path.abspath(mlflow_home) if mlflow_home else None\n    with TempDir() as tmp:\n        cwd = tmp.path()\n        install_mlflow = _get_mlflow_install_step(cwd, mlflow_home)\n        custom_setup_steps = custom_setup_steps_hook(cwd) if custom_setup_steps_hook else \"\"\n        with open(os.path.join(cwd, \"Dockerfile\"), \"w\") as f:\n            f.write(_DOCKERFILE_TEMPLATE.format(\n                install_mlflow=install_mlflow, custom_setup_steps=custom_setup_steps,\n                entrypoint=entrypoint))\n        _logger.info(\"Building docker image with name %s\", image_name)\n        os.system('find {cwd}/'.format(cwd=cwd))\n        proc = Popen([\"docker\", \"build\", \"-t\", image_name, \"-f\", \"Dockerfile\", \".\"],\n                     cwd=cwd,\n                     stdout=PIPE,\n                     stderr=STDOUT,\n                     universal_newlines=True)\n        for x in iter(proc.stdout.readline, \"\"):\n            eprint(x, end='')\n", "path": "mlflow/models/docker_utils.py"}], "after_files": [{"content": "import os\nfrom subprocess import Popen, PIPE, STDOUT\nimport logging\n\nimport mlflow\nimport mlflow.version\nfrom mlflow.utils.file_utils import TempDir, _copy_project\nfrom mlflow.utils.logging_utils import eprint\n\n_logger = logging.getLogger(__name__)\n\nDISABLE_ENV_CREATION = \"MLFLOW_DISABLE_ENV_CREATION\"\n\n_DOCKERFILE_TEMPLATE = \"\"\"\n# Build an image that can serve mlflow models.\nFROM ubuntu:18.04\n\nRUN apt-get -y update && apt-get install -y --no-install-recommends \\\n         wget \\\n         curl \\\n         nginx \\\n         ca-certificates \\\n         bzip2 \\\n         build-essential \\\n         cmake \\\n         openjdk-8-jdk \\\n         git-core \\\n         maven \\\n    && rm -rf /var/lib/apt/lists/*\n\n# Download and setup miniconda\nRUN curl -L https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh >> miniconda.sh\nRUN bash ./miniconda.sh -b -p /miniconda; rm ./miniconda.sh;\nENV PATH=\"/miniconda/bin:$PATH\"\nENV JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64\nENV GUNICORN_CMD_ARGS=\"--timeout 60 -k gevent\"\n# Set up the program in the image\nWORKDIR /opt/mlflow\n\n{install_mlflow}\n\n{custom_setup_steps}\n{entrypoint}\n\"\"\"\n\n\ndef _get_mlflow_install_step(dockerfile_context_dir, mlflow_home):\n    \"\"\"\n    Get docker build commands for installing MLflow given a Docker context dir and optional source\n    directory\n    \"\"\"\n    if mlflow_home:\n        mlflow_dir = _copy_project(\n            src_path=mlflow_home, dst_path=dockerfile_context_dir)\n        return (\n            \"COPY {mlflow_dir} /opt/mlflow\\n\"\n            \"RUN pip install /opt/mlflow\\n\"\n            \"RUN cd /opt/mlflow/mlflow/java/scoring && \"\n            \"mvn --batch-mode package -DskipTests && \"\n            \"mkdir -p /opt/java/jars && \"\n            \"mv /opt/mlflow/mlflow/java/scoring/target/\"\n            \"mlflow-scoring-*-with-dependencies.jar /opt/java/jars\\n\"\n        ).format(mlflow_dir=mlflow_dir)\n    else:\n        return (\n            \"RUN pip install mlflow=={version}\\n\"\n            \"RUN mvn \"\n            \" --batch-mode dependency:copy\"\n            \" -Dartifact=org.mlflow:mlflow-scoring:{version}:pom\"\n            \" -DoutputDirectory=/opt/java\\n\"\n            \"RUN mvn \"\n            \" --batch-mode dependency:copy\"\n            \" -Dartifact=org.mlflow:mlflow-scoring:{version}:jar\"\n            \" -DoutputDirectory=/opt/java/jars\\n\"\n            \"RUN cp /opt/java/mlflow-scoring-{version}.pom /opt/java/pom.xml\\n\"\n            \"RUN cd /opt/java && mvn \"\n            \"--batch-mode dependency:copy-dependencies -DoutputDirectory=/opt/java/jars\\n\"\n        ).format(version=mlflow.version.VERSION)\n\n\ndef _build_image(image_name, entrypoint, mlflow_home=None, custom_setup_steps_hook=None):\n    \"\"\"\n    Build an MLflow Docker image that can be used to serve a\n    The image is built locally and it requires Docker to run.\n\n    :param image_name: Docker image name.\n    :param entry_point: String containing ENTRYPOINT directive for docker image\n    :param mlflow_home: (Optional) Path to a local copy of the MLflow GitHub repository.\n                        If specified, the image will install MLflow from this directory.\n                        If None, it will install MLflow from pip.\n    :param custom_setup_steps_hook: (Optional) Single-argument function that takes the string path\n           of a dockerfile context directory and returns a string containing Dockerfile commands to\n           run during the image build step.\n    \"\"\"\n    mlflow_home = os.path.abspath(mlflow_home) if mlflow_home else None\n    with TempDir() as tmp:\n        cwd = tmp.path()\n        install_mlflow = _get_mlflow_install_step(cwd, mlflow_home)\n        custom_setup_steps = custom_setup_steps_hook(cwd) if custom_setup_steps_hook else \"\"\n        with open(os.path.join(cwd, \"Dockerfile\"), \"w\") as f:\n            f.write(_DOCKERFILE_TEMPLATE.format(\n                install_mlflow=install_mlflow, custom_setup_steps=custom_setup_steps,\n                entrypoint=entrypoint))\n        _logger.info(\"Building docker image with name %s\", image_name)\n        os.system('find {cwd}/'.format(cwd=cwd))\n        proc = Popen([\"docker\", \"build\", \"-t\", image_name, \"-f\", \"Dockerfile\", \".\"],\n                     cwd=cwd,\n                     stdout=PIPE,\n                     stderr=STDOUT,\n                     universal_newlines=True)\n        for x in iter(proc.stdout.readline, \"\"):\n            eprint(x, end='')\n", "path": "mlflow/models/docker_utils.py"}]}