Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions build/core/build_center.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,16 @@

class BuildCenter:

def __init__(self, build_config, process_list, type):
def __init__(self, build_config, process_list, type, arg_config=None):

self.logger = logging.getLogger(__name__)
build_utility.setup_logger_config(self.logger)

self.build_config = build_config
self.task_type = type

self.arg_config = arg_config

self.process_list = [service.lower() for service in process_list] if process_list is not None else None

# Initialize docker_cli instance
Expand Down Expand Up @@ -138,7 +140,7 @@ def build_center(self):
for inedge in self.graph.services[item].inedges:
build_worker.copy_dependency_folder(os.path.join(self.codeDir,inedge),
os.path.join(self.graph.services[item].path,self.dependencyDir+inedge))
build_worker.build_single_component(self.graph.services[item])
build_worker.build_single_component(self.graph.services[item], self.arg_config.imagelist)
self.logger.info("Build all components succeed")

except Exception as e:
Expand Down
5 changes: 3 additions & 2 deletions build/core/build_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def __init__(self, docker_cli):
self.dependencyDir = 'dependency'


def build_single_component(self, service):
def build_single_component(self, service, imagelist=None):

self.logger.info("Starts to build {0}".format(service.service_name))

Expand All @@ -53,7 +53,8 @@ def build_single_component(self, service):
for dockerfile_prefix in service.docker_files:
image_name = os.path.splitext(dockerfile_prefix)[0]
dockerfile = os.path.join(service.path, 'build/' + dockerfile_prefix + '.dockerfile')
self.docker_cli.docker_image_build(image_name, dockerfile, service.path)
if imagelist is None or image_name in imagelist:
self.docker_cli.docker_image_build(image_name, dockerfile, service.path)

post_build = os.path.join(service.path, self.build_post)
if os.path.exists(post_build):
Expand Down
8 changes: 7 additions & 1 deletion build/pai_build.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def load_build_config(config_dir):


def build_service(args, config_model):
pai_build = build_center.BuildCenter(config_model, args.service, 'k8s')
pai_build = build_center.BuildCenter(config_model, args.service, 'k8s', args)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why not args.imagelist directly?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it is reserved for possible update which may use other args.

pai_build.set_build_cache_type(args.nocache)
pai_build.build_center()

Expand Down Expand Up @@ -98,6 +98,12 @@ def main():
action='store_true',
help="Build the service using cache or not"
)
build_parser.add_argument(
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can this args be used when push

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, the push has -i option to push a single image to the server.

'-i', '--imagelist',
type=str,
nargs='+',
help="The image list you want to build"
)
build_parser.set_defaults(func=build_service)

# Push commands
Expand Down