in ftl/node/layer_builder.py [0:0]
def BuildLayer(self):
"""Override."""
cached_img = None
is_gcp_build = False
if self._ctx and self._ctx.Contains(constants.PACKAGE_JSON):
is_gcp_build = ftl_util.is_gcp_build(
json.loads(self._ctx.GetFile(constants.PACKAGE_JSON)))
if is_gcp_build:
env = {"NODE_ENV": "development"}
if self._should_use_yarn:
ftl_util.gcp_build(self._directory, 'yarn', 'run', env_map=env)
self._cleanup_build_layer()
else:
ftl_util.gcp_build(self._directory, 'npm', 'run-script',
env_map=env)
self._cleanup_build_layer()
key = self.GetCacheKey()
if self._cache:
with ftl_util.Timing('checking_cached_packages_json_layer'):
cached_img = self._cache.Get(key)
self._log_cache_result(False if cached_img is None else True,
key)
if cached_img:
self.SetImage(cached_img)
else:
with ftl_util.Timing('building_packages_json_layer'):
self._build_layer()
self._cleanup_build_layer()
if self._cache:
with ftl_util.Timing('uploading_packages_json_layer'):
self._cache.Set(key, self.GetImage())