in src/image.py [0:0]
def build(self):
"""
The build function sets the stage for starting the docker build process for a given image.
:return: int, Build Status
"""
self.summary["start_time"] = datetime.now()
# Confirm if building the image is required or not
if not self.to_build:
self.log.append(["Not built"])
self.build_status = constants.NOT_BUILT
self.summary["status"] = constants.STATUS_MESSAGE[self.build_status]
return self.build_status
# Conduct some preprocessing before building the image
self.update_pre_build_configuration()
# Start building the image
with open(self.context.context_path, "rb") as context_file:
self.docker_build(fileobj=context_file, custom_context=True)
self.context.remove()
if self.build_status != constants.SUCCESS:
LOGGER.info(f"Exiting with image build status {self.build_status} without image check.")
return self.build_status
if not self.to_push:
# If this image is not supposed to be pushed, in that case, we are already done
# with building the image and do not need to conduct any further processing.
self.summary["end_time"] = datetime.now()
# check the size after image is built.
self.image_size_check()
# This return is necessary. Otherwise FORMATTER fails while displaying the status.
return self.build_status