We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
`sam build` for Gradle using gradlew does not work with --use-container
<!-- Make sure we don't have an existing Issue that reports the bug you are seeing (both open and closed). 
If you do find an existing Issue, re-open or add a comment to that Issue instead of creating a new one. -->

### Description

Briefly describe the bug you are facing.
When a Gradle project uses `gradlew` scripts, this file does not get picked up with building inside a container.

### Steps to reproduce

Provide steps to replicate.
This integration test sets everything up to repro this issue - https://github.com/awslabs/aws-sam-cli/blob/develop/tests/integration/buildcmd/test_build_cmd.py#L256


### Observed result

Please provide command output with `--debug` flag set.
`gradle` installation within the container is used instead of the `gradlew` script

### Expected result

Describe what you expected.
`gradlew` script is used to build the project 

### Additional environment details (Ex: Windows, Mac, Amazon Linux etc)

1. OS:
2. `sam --version`:

`Add --debug flag to command you are running`

--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `samcli/local/docker/lambda_build_container.py`
Content:
```
1 """
2 Represents Lambda Build Containers.
3 """
4 
5 import json
6 import logging
7 
8 try:
9     import pathlib
10 except ImportError:
11     import pathlib2 as pathlib
12 
13 from .container import Container
14 
15 LOG = logging.getLogger(__name__)
16 
17 
18 class LambdaBuildContainer(Container):
19     """
20     Class to manage Build containers that are capable of building AWS Lambda functions.
21     This container mounts necessary folders, issues a command to the Lambda Builder CLI,
22     and if the build was successful, copies back artifacts to the host filesystem
23     """
24 
25     _IMAGE_REPO_NAME = "lambci/lambda"
26     _BUILDERS_EXECUTABLE = "lambda-builders"
27 
28     def __init__(self,  # pylint: disable=too-many-locals
29                  protocol_version,
30                  language,
31                  dependency_manager,
32                  application_framework,
33                  source_dir,
34                  manifest_path,
35                  runtime,
36                  optimizations=None,
37                  options=None,
38                  executable_search_paths=None,
39                  log_level=None):
40 
41         abs_manifest_path = pathlib.Path(manifest_path).resolve()
42         manifest_file_name = abs_manifest_path.name
43         manifest_dir = str(abs_manifest_path.parent)
44 
45         source_dir = str(pathlib.Path(source_dir).resolve())
46 
47         container_dirs = LambdaBuildContainer._get_container_dirs(source_dir, manifest_dir)
48 
49         request_json = self._make_request(protocol_version,
50                                           language,
51                                           dependency_manager,
52                                           application_framework,
53                                           container_dirs,
54                                           manifest_file_name,
55                                           runtime,
56                                           optimizations,
57                                           options,
58                                           executable_search_paths)
59 
60         image = LambdaBuildContainer._get_image(runtime)
61         entry = LambdaBuildContainer._get_entrypoint(request_json)
62         cmd = []
63 
64         additional_volumes = {
65             # Manifest is mounted separately in order to support the case where manifest
66             # is outside of source directory
67             manifest_dir: {
68                 "bind": container_dirs["manifest_dir"],
69                 "mode": "ro"
70             }
71         }
72 
73         env_vars = None
74         if log_level:
75             env_vars = {
76                 "LAMBDA_BUILDERS_LOG_LEVEL": log_level
77             }
78 
79         super(LambdaBuildContainer, self).__init__(
80             image,
81             cmd,
82             container_dirs["source_dir"],
83             source_dir,
84             additional_volumes=additional_volumes,
85             entrypoint=entry,
86             env_vars=env_vars)
87 
88     @property
89     def executable_name(self):
90         return LambdaBuildContainer._BUILDERS_EXECUTABLE
91 
92     @staticmethod
93     def _make_request(protocol_version,
94                       language,
95                       dependency_manager,
96                       application_framework,
97                       container_dirs,
98                       manifest_file_name,
99                       runtime,
100                       optimizations,
101                       options,
102                       executable_search_paths):
103 
104         return json.dumps({
105             "jsonschema": "2.0",
106             "id": 1,
107             "method": "LambdaBuilder.build",
108             "params": {
109                 "__protocol_version": protocol_version,
110                 "capability": {
111                     "language": language,
112                     "dependency_manager": dependency_manager,
113                     "application_framework": application_framework
114                 },
115                 "source_dir": container_dirs["source_dir"],
116                 "artifacts_dir": container_dirs["artifacts_dir"],
117                 "scratch_dir": container_dirs["scratch_dir"],
118 
119                 # Path is always inside a Linux container. So '/' is valid
120                 "manifest_path": "{}/{}".format(container_dirs["manifest_dir"], manifest_file_name),
121 
122                 "runtime": runtime,
123                 "optimizations": optimizations,
124                 "options": options,
125                 "executable_search_paths": executable_search_paths
126             }
127         })
128 
129     @staticmethod
130     def _get_entrypoint(request_json):
131         return [LambdaBuildContainer._BUILDERS_EXECUTABLE, request_json]
132 
133     @staticmethod
134     def _get_container_dirs(source_dir, manifest_dir):
135         """
136         Provides paths to directories within the container that is required by the builder
137 
138         Parameters
139         ----------
140         source_dir : str
141             Path to the function source code
142 
143         manifest_dir : str
144             Path to the directory containing manifest
145 
146         Returns
147         -------
148         dict
149             Contains paths to source, artifacts, scratch & manifest directories
150         """
151         base = "/tmp/samcli"
152         result = {
153             "source_dir": "{}/source".format(base),
154             "artifacts_dir": "{}/artifacts".format(base),
155             "scratch_dir": "{}/scratch".format(base),
156             "manifest_dir": "{}/manifest".format(base)
157         }
158 
159         if pathlib.PurePath(source_dir) == pathlib.PurePath(manifest_dir):
160             # It is possible that the manifest resides within the source. In that case, we won't mount the manifest
161             # directory separately.
162             result["manifest_dir"] = result["source_dir"]
163 
164         return result
165 
166     @staticmethod
167     def _get_image(runtime):
168         return "{}:build-{}".format(LambdaBuildContainer._IMAGE_REPO_NAME, runtime)
169
```
--- 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/samcli/local/docker/lambda_build_container.py b/samcli/local/docker/lambda_build_container.py
--- a/samcli/local/docker/lambda_build_container.py
+++ b/samcli/local/docker/lambda_build_container.py
@@ -46,6 +46,18 @@
 
         container_dirs = LambdaBuildContainer._get_container_dirs(source_dir, manifest_dir)
 
+        # `executable_search_paths` are provided as a list of paths on the host file system that needs to passed to
+        # the builder. But these paths don't exist within the container. We use the following method to convert the
+        # host paths to container paths. But if a host path is NOT mounted within the container, we will simply ignore
+        # it. In essence, only when the path is already in the mounted path, can the path resolver within the
+        # container even find the executable.
+        executable_search_paths = LambdaBuildContainer._convert_to_container_dirs(
+            host_paths_to_convert=executable_search_paths,
+            host_to_container_path_mapping={
+                source_dir: container_dirs["source_dir"],
+                manifest_dir: container_dirs["manifest_dir"]
+            })
+
         request_json = self._make_request(protocol_version,
                                           language,
                                           dependency_manager,
@@ -163,6 +175,54 @@
 
         return result
 
+    @staticmethod
+    def _convert_to_container_dirs(host_paths_to_convert, host_to_container_path_mapping):
+        """
+        Use this method to convert a list of host paths to a list of equivalent paths within the container
+        where the given host path is mounted. This is necessary when SAM CLI needs to pass path information to
+        the Lambda Builder running within the container.
+
+        If a host path is not mounted within the container, then this method simply passes the path to the result
+        without any changes.
+
+        Ex:
+            [ "/home/foo", "/home/bar", "/home/not/mounted"]  => ["/tmp/source", "/tmp/manifest", "/home/not/mounted"]
+
+        Parameters
+        ----------
+        host_paths_to_convert : list
+            List of paths in host that needs to be converted
+
+        host_to_container_path_mapping : dict
+            Mapping of paths in host to the equivalent paths within the container
+
+        Returns
+        -------
+        list
+            Equivalent paths within the container
+        """
+
+        if not host_paths_to_convert:
+            # Nothing to do
+            return host_paths_to_convert
+
+        # Make sure the key is absolute host path. Relative paths are tricky to work with because two different
+        # relative paths can point to the same directory ("../foo", "../../foo")
+        mapping = {str(pathlib.Path(p).resolve()): v for p, v in host_to_container_path_mapping.items()}
+
+        result = []
+        for original_path in host_paths_to_convert:
+            abspath = str(pathlib.Path(original_path).resolve())
+
+            if abspath in mapping:
+                result.append(mapping[abspath])
+            else:
+                result.append(original_path)
+                LOG.debug("Cannot convert host path '%s' to its equivalent path within the container. "
+                          "Host path is not mounted within the container", abspath)
+
+        return result
+
     @staticmethod
     def _get_image(runtime):
         return "{}:build-{}".format(LambdaBuildContainer._IMAGE_REPO_NAME, runtime)

{"golden_diff": "diff --git a/samcli/local/docker/lambda_build_container.py b/samcli/local/docker/lambda_build_container.py\n--- a/samcli/local/docker/lambda_build_container.py\n+++ b/samcli/local/docker/lambda_build_container.py\n@@ -46,6 +46,18 @@\n \n         container_dirs = LambdaBuildContainer._get_container_dirs(source_dir, manifest_dir)\n \n+        # `executable_search_paths` are provided as a list of paths on the host file system that needs to passed to\n+        # the builder. But these paths don't exist within the container. We use the following method to convert the\n+        # host paths to container paths. But if a host path is NOT mounted within the container, we will simply ignore\n+        # it. In essence, only when the path is already in the mounted path, can the path resolver within the\n+        # container even find the executable.\n+        executable_search_paths = LambdaBuildContainer._convert_to_container_dirs(\n+            host_paths_to_convert=executable_search_paths,\n+            host_to_container_path_mapping={\n+                source_dir: container_dirs[\"source_dir\"],\n+                manifest_dir: container_dirs[\"manifest_dir\"]\n+            })\n+\n         request_json = self._make_request(protocol_version,\n                                           language,\n                                           dependency_manager,\n@@ -163,6 +175,54 @@\n \n         return result\n \n+    @staticmethod\n+    def _convert_to_container_dirs(host_paths_to_convert, host_to_container_path_mapping):\n+        \"\"\"\n+        Use this method to convert a list of host paths to a list of equivalent paths within the container\n+        where the given host path is mounted. This is necessary when SAM CLI needs to pass path information to\n+        the Lambda Builder running within the container.\n+\n+        If a host path is not mounted within the container, then this method simply passes the path to the result\n+        without any changes.\n+\n+        Ex:\n+            [ \"/home/foo\", \"/home/bar\", \"/home/not/mounted\"]  => [\"/tmp/source\", \"/tmp/manifest\", \"/home/not/mounted\"]\n+\n+        Parameters\n+        ----------\n+        host_paths_to_convert : list\n+            List of paths in host that needs to be converted\n+\n+        host_to_container_path_mapping : dict\n+            Mapping of paths in host to the equivalent paths within the container\n+\n+        Returns\n+        -------\n+        list\n+            Equivalent paths within the container\n+        \"\"\"\n+\n+        if not host_paths_to_convert:\n+            # Nothing to do\n+            return host_paths_to_convert\n+\n+        # Make sure the key is absolute host path. Relative paths are tricky to work with because two different\n+        # relative paths can point to the same directory (\"../foo\", \"../../foo\")\n+        mapping = {str(pathlib.Path(p).resolve()): v for p, v in host_to_container_path_mapping.items()}\n+\n+        result = []\n+        for original_path in host_paths_to_convert:\n+            abspath = str(pathlib.Path(original_path).resolve())\n+\n+            if abspath in mapping:\n+                result.append(mapping[abspath])\n+            else:\n+                result.append(original_path)\n+                LOG.debug(\"Cannot convert host path '%s' to its equivalent path within the container. \"\n+                          \"Host path is not mounted within the container\", abspath)\n+\n+        return result\n+\n     @staticmethod\n     def _get_image(runtime):\n         return \"{}:build-{}\".format(LambdaBuildContainer._IMAGE_REPO_NAME, runtime)\n", "issue": "`sam build` for Gradle using gradlew does not work with --use-container\n<!-- Make sure we don't have an existing Issue that reports the bug you are seeing (both open and closed). \r\nIf you do find an existing Issue, re-open or add a comment to that Issue instead of creating a new one. -->\r\n\r\n### Description\r\n\r\nBriefly describe the bug you are facing.\r\nWhen a Gradle project uses `gradlew` scripts, this file does not get picked up with building inside a container.\r\n\r\n### Steps to reproduce\r\n\r\nProvide steps to replicate.\r\nThis integration test sets everything up to repro this issue - https://github.com/awslabs/aws-sam-cli/blob/develop/tests/integration/buildcmd/test_build_cmd.py#L256\r\n\r\n\r\n### Observed result\r\n\r\nPlease provide command output with `--debug` flag set.\r\n`gradle` installation within the container is used instead of the `gradlew` script\r\n\r\n### Expected result\r\n\r\nDescribe what you expected.\r\n`gradlew` script is used to build the project \r\n\r\n### Additional environment details (Ex: Windows, Mac, Amazon Linux etc)\r\n\r\n1. OS:\r\n2. `sam --version`:\r\n\r\n`Add --debug flag to command you are running`\n", "before_files": [{"content": "\"\"\"\nRepresents Lambda Build Containers.\n\"\"\"\n\nimport json\nimport logging\n\ntry:\n    import pathlib\nexcept ImportError:\n    import pathlib2 as pathlib\n\nfrom .container import Container\n\nLOG = logging.getLogger(__name__)\n\n\nclass LambdaBuildContainer(Container):\n    \"\"\"\n    Class to manage Build containers that are capable of building AWS Lambda functions.\n    This container mounts necessary folders, issues a command to the Lambda Builder CLI,\n    and if the build was successful, copies back artifacts to the host filesystem\n    \"\"\"\n\n    _IMAGE_REPO_NAME = \"lambci/lambda\"\n    _BUILDERS_EXECUTABLE = \"lambda-builders\"\n\n    def __init__(self,  # pylint: disable=too-many-locals\n                 protocol_version,\n                 language,\n                 dependency_manager,\n                 application_framework,\n                 source_dir,\n                 manifest_path,\n                 runtime,\n                 optimizations=None,\n                 options=None,\n                 executable_search_paths=None,\n                 log_level=None):\n\n        abs_manifest_path = pathlib.Path(manifest_path).resolve()\n        manifest_file_name = abs_manifest_path.name\n        manifest_dir = str(abs_manifest_path.parent)\n\n        source_dir = str(pathlib.Path(source_dir).resolve())\n\n        container_dirs = LambdaBuildContainer._get_container_dirs(source_dir, manifest_dir)\n\n        request_json = self._make_request(protocol_version,\n                                          language,\n                                          dependency_manager,\n                                          application_framework,\n                                          container_dirs,\n                                          manifest_file_name,\n                                          runtime,\n                                          optimizations,\n                                          options,\n                                          executable_search_paths)\n\n        image = LambdaBuildContainer._get_image(runtime)\n        entry = LambdaBuildContainer._get_entrypoint(request_json)\n        cmd = []\n\n        additional_volumes = {\n            # Manifest is mounted separately in order to support the case where manifest\n            # is outside of source directory\n            manifest_dir: {\n                \"bind\": container_dirs[\"manifest_dir\"],\n                \"mode\": \"ro\"\n            }\n        }\n\n        env_vars = None\n        if log_level:\n            env_vars = {\n                \"LAMBDA_BUILDERS_LOG_LEVEL\": log_level\n            }\n\n        super(LambdaBuildContainer, self).__init__(\n            image,\n            cmd,\n            container_dirs[\"source_dir\"],\n            source_dir,\n            additional_volumes=additional_volumes,\n            entrypoint=entry,\n            env_vars=env_vars)\n\n    @property\n    def executable_name(self):\n        return LambdaBuildContainer._BUILDERS_EXECUTABLE\n\n    @staticmethod\n    def _make_request(protocol_version,\n                      language,\n                      dependency_manager,\n                      application_framework,\n                      container_dirs,\n                      manifest_file_name,\n                      runtime,\n                      optimizations,\n                      options,\n                      executable_search_paths):\n\n        return json.dumps({\n            \"jsonschema\": \"2.0\",\n            \"id\": 1,\n            \"method\": \"LambdaBuilder.build\",\n            \"params\": {\n                \"__protocol_version\": protocol_version,\n                \"capability\": {\n                    \"language\": language,\n                    \"dependency_manager\": dependency_manager,\n                    \"application_framework\": application_framework\n                },\n                \"source_dir\": container_dirs[\"source_dir\"],\n                \"artifacts_dir\": container_dirs[\"artifacts_dir\"],\n                \"scratch_dir\": container_dirs[\"scratch_dir\"],\n\n                # Path is always inside a Linux container. So '/' is valid\n                \"manifest_path\": \"{}/{}\".format(container_dirs[\"manifest_dir\"], manifest_file_name),\n\n                \"runtime\": runtime,\n                \"optimizations\": optimizations,\n                \"options\": options,\n                \"executable_search_paths\": executable_search_paths\n            }\n        })\n\n    @staticmethod\n    def _get_entrypoint(request_json):\n        return [LambdaBuildContainer._BUILDERS_EXECUTABLE, request_json]\n\n    @staticmethod\n    def _get_container_dirs(source_dir, manifest_dir):\n        \"\"\"\n        Provides paths to directories within the container that is required by the builder\n\n        Parameters\n        ----------\n        source_dir : str\n            Path to the function source code\n\n        manifest_dir : str\n            Path to the directory containing manifest\n\n        Returns\n        -------\n        dict\n            Contains paths to source, artifacts, scratch & manifest directories\n        \"\"\"\n        base = \"/tmp/samcli\"\n        result = {\n            \"source_dir\": \"{}/source\".format(base),\n            \"artifacts_dir\": \"{}/artifacts\".format(base),\n            \"scratch_dir\": \"{}/scratch\".format(base),\n            \"manifest_dir\": \"{}/manifest\".format(base)\n        }\n\n        if pathlib.PurePath(source_dir) == pathlib.PurePath(manifest_dir):\n            # It is possible that the manifest resides within the source. In that case, we won't mount the manifest\n            # directory separately.\n            result[\"manifest_dir\"] = result[\"source_dir\"]\n\n        return result\n\n    @staticmethod\n    def _get_image(runtime):\n        return \"{}:build-{}\".format(LambdaBuildContainer._IMAGE_REPO_NAME, runtime)\n", "path": "samcli/local/docker/lambda_build_container.py"}], "after_files": [{"content": "\"\"\"\nRepresents Lambda Build Containers.\n\"\"\"\n\nimport json\nimport logging\n\ntry:\n    import pathlib\nexcept ImportError:\n    import pathlib2 as pathlib\n\nfrom .container import Container\n\nLOG = logging.getLogger(__name__)\n\n\nclass LambdaBuildContainer(Container):\n    \"\"\"\n    Class to manage Build containers that are capable of building AWS Lambda functions.\n    This container mounts necessary folders, issues a command to the Lambda Builder CLI,\n    and if the build was successful, copies back artifacts to the host filesystem\n    \"\"\"\n\n    _IMAGE_REPO_NAME = \"lambci/lambda\"\n    _BUILDERS_EXECUTABLE = \"lambda-builders\"\n\n    def __init__(self,  # pylint: disable=too-many-locals\n                 protocol_version,\n                 language,\n                 dependency_manager,\n                 application_framework,\n                 source_dir,\n                 manifest_path,\n                 runtime,\n                 optimizations=None,\n                 options=None,\n                 executable_search_paths=None,\n                 log_level=None):\n\n        abs_manifest_path = pathlib.Path(manifest_path).resolve()\n        manifest_file_name = abs_manifest_path.name\n        manifest_dir = str(abs_manifest_path.parent)\n\n        source_dir = str(pathlib.Path(source_dir).resolve())\n\n        container_dirs = LambdaBuildContainer._get_container_dirs(source_dir, manifest_dir)\n\n        # `executable_search_paths` are provided as a list of paths on the host file system that needs to passed to\n        # the builder. But these paths don't exist within the container. We use the following method to convert the\n        # host paths to container paths. But if a host path is NOT mounted within the container, we will simply ignore\n        # it. In essence, only when the path is already in the mounted path, can the path resolver within the\n        # container even find the executable.\n        executable_search_paths = LambdaBuildContainer._convert_to_container_dirs(\n            host_paths_to_convert=executable_search_paths,\n            host_to_container_path_mapping={\n                source_dir: container_dirs[\"source_dir\"],\n                manifest_dir: container_dirs[\"manifest_dir\"]\n            })\n\n        request_json = self._make_request(protocol_version,\n                                          language,\n                                          dependency_manager,\n                                          application_framework,\n                                          container_dirs,\n                                          manifest_file_name,\n                                          runtime,\n                                          optimizations,\n                                          options,\n                                          executable_search_paths)\n\n        image = LambdaBuildContainer._get_image(runtime)\n        entry = LambdaBuildContainer._get_entrypoint(request_json)\n        cmd = []\n\n        additional_volumes = {\n            # Manifest is mounted separately in order to support the case where manifest\n            # is outside of source directory\n            manifest_dir: {\n                \"bind\": container_dirs[\"manifest_dir\"],\n                \"mode\": \"ro\"\n            }\n        }\n\n        env_vars = None\n        if log_level:\n            env_vars = {\n                \"LAMBDA_BUILDERS_LOG_LEVEL\": log_level\n            }\n\n        super(LambdaBuildContainer, self).__init__(\n            image,\n            cmd,\n            container_dirs[\"source_dir\"],\n            source_dir,\n            additional_volumes=additional_volumes,\n            entrypoint=entry,\n            env_vars=env_vars)\n\n    @property\n    def executable_name(self):\n        return LambdaBuildContainer._BUILDERS_EXECUTABLE\n\n    @staticmethod\n    def _make_request(protocol_version,\n                      language,\n                      dependency_manager,\n                      application_framework,\n                      container_dirs,\n                      manifest_file_name,\n                      runtime,\n                      optimizations,\n                      options,\n                      executable_search_paths):\n\n        return json.dumps({\n            \"jsonschema\": \"2.0\",\n            \"id\": 1,\n            \"method\": \"LambdaBuilder.build\",\n            \"params\": {\n                \"__protocol_version\": protocol_version,\n                \"capability\": {\n                    \"language\": language,\n                    \"dependency_manager\": dependency_manager,\n                    \"application_framework\": application_framework\n                },\n                \"source_dir\": container_dirs[\"source_dir\"],\n                \"artifacts_dir\": container_dirs[\"artifacts_dir\"],\n                \"scratch_dir\": container_dirs[\"scratch_dir\"],\n\n                # Path is always inside a Linux container. So '/' is valid\n                \"manifest_path\": \"{}/{}\".format(container_dirs[\"manifest_dir\"], manifest_file_name),\n\n                \"runtime\": runtime,\n                \"optimizations\": optimizations,\n                \"options\": options,\n                \"executable_search_paths\": executable_search_paths\n            }\n        })\n\n    @staticmethod\n    def _get_entrypoint(request_json):\n        return [LambdaBuildContainer._BUILDERS_EXECUTABLE, request_json]\n\n    @staticmethod\n    def _get_container_dirs(source_dir, manifest_dir):\n        \"\"\"\n        Provides paths to directories within the container that is required by the builder\n\n        Parameters\n        ----------\n        source_dir : str\n            Path to the function source code\n\n        manifest_dir : str\n            Path to the directory containing manifest\n\n        Returns\n        -------\n        dict\n            Contains paths to source, artifacts, scratch & manifest directories\n        \"\"\"\n        base = \"/tmp/samcli\"\n        result = {\n            \"source_dir\": \"{}/source\".format(base),\n            \"artifacts_dir\": \"{}/artifacts\".format(base),\n            \"scratch_dir\": \"{}/scratch\".format(base),\n            \"manifest_dir\": \"{}/manifest\".format(base)\n        }\n\n        if pathlib.PurePath(source_dir) == pathlib.PurePath(manifest_dir):\n            # It is possible that the manifest resides within the source. In that case, we won't mount the manifest\n            # directory separately.\n            result[\"manifest_dir\"] = result[\"source_dir\"]\n\n        return result\n\n    @staticmethod\n    def _convert_to_container_dirs(host_paths_to_convert, host_to_container_path_mapping):\n        \"\"\"\n        Use this method to convert a list of host paths to a list of equivalent paths within the container\n        where the given host path is mounted. This is necessary when SAM CLI needs to pass path information to\n        the Lambda Builder running within the container.\n\n        If a host path is not mounted within the container, then this method simply passes the path to the result\n        without any changes.\n\n        Ex:\n            [ \"/home/foo\", \"/home/bar\", \"/home/not/mounted\"]  => [\"/tmp/source\", \"/tmp/manifest\", \"/home/not/mounted\"]\n\n        Parameters\n        ----------\n        host_paths_to_convert : list\n            List of paths in host that needs to be converted\n\n        host_to_container_path_mapping : dict\n            Mapping of paths in host to the equivalent paths within the container\n\n        Returns\n        -------\n        list\n            Equivalent paths within the container\n        \"\"\"\n\n        if not host_paths_to_convert:\n            # Nothing to do\n            return host_paths_to_convert\n\n        # Make sure the key is absolute host path. Relative paths are tricky to work with because two different\n        # relative paths can point to the same directory (\"../foo\", \"../../foo\")\n        mapping = {str(pathlib.Path(p).resolve()): v for p, v in host_to_container_path_mapping.items()}\n\n        result = []\n        for original_path in host_paths_to_convert:\n            abspath = str(pathlib.Path(original_path).resolve())\n\n            if abspath in mapping:\n                result.append(mapping[abspath])\n            else:\n                result.append(original_path)\n                LOG.debug(\"Cannot convert host path '%s' to its equivalent path within the container. \"\n                          \"Host path is not mounted within the container\", abspath)\n\n        return result\n\n    @staticmethod\n    def _get_image(runtime):\n        return \"{}:build-{}\".format(LambdaBuildContainer._IMAGE_REPO_NAME, runtime)\n", "path": "samcli/local/docker/lambda_build_container.py"}]}