Refactor, support build-webapp
	
		
			
	
		
	
	
		
	
		
			All checks were successful
		
		
	
	
		
			
				
	
				Lint Checks / Run linter (pull_request) Successful in 39s
				
			
		
			
				
	
				Webapp Test / Run webapp test suite (pull_request) Successful in 3m21s
				
			
		
			
				
	
				Deploy Test / Run deploy test suite (pull_request) Successful in 4m52s
				
			
		
			
				
	
				K8s Deploy Test / Run deploy test suite on kind/k8s (pull_request) Successful in 6m15s
				
			
		
			
				
	
				Smoke Test / Run basic test suite (pull_request) Successful in 3m3s
				
			
		
		
	
	
				
					
				
			
		
			All checks were successful
		
		
	
	Lint Checks / Run linter (pull_request) Successful in 39s
				
			Webapp Test / Run webapp test suite (pull_request) Successful in 3m21s
				
			Deploy Test / Run deploy test suite (pull_request) Successful in 4m52s
				
			K8s Deploy Test / Run deploy test suite on kind/k8s (pull_request) Successful in 6m15s
				
			Smoke Test / Run basic test suite (pull_request) Successful in 3m3s
				
			This commit is contained in:
		
							parent
							
								
									5690303181
								
							
						
					
					
						commit
						a389285fb1
					
				| @ -62,7 +62,7 @@ def make_container_build_env(dev_root_path: str, | |||||||
|     return container_build_env |     return container_build_env | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| def process_container(build_context: BuildContext): | def process_container(build_context: BuildContext) -> bool: | ||||||
|     if not opts.o.quiet: |     if not opts.o.quiet: | ||||||
|         print(f"Building: {build_context.container}") |         print(f"Building: {build_context.container}") | ||||||
| 
 | 
 | ||||||
| @ -108,17 +108,12 @@ def process_container(build_context: BuildContext): | |||||||
|         if opts.o.verbose: |         if opts.o.verbose: | ||||||
|             print(f"Return code is: {build_result.returncode}") |             print(f"Return code is: {build_result.returncode}") | ||||||
|         if build_result.returncode != 0: |         if build_result.returncode != 0: | ||||||
|             print(f"Error running build for {build_context.container}") |             return False | ||||||
|             if not opts.o.continue_on_error: |  | ||||||
|                 print("FATAL Error: container build failed and --continue-on-error not set, exiting") |  | ||||||
|                 sys.exit(1) |  | ||||||
|             else: |  | ||||||
|                 print("****** Container Build Error, continuing because --continue-on-error is set") |  | ||||||
|         else: |         else: | ||||||
|             if build_context.publish_images: |             return True | ||||||
|                 publish_image(default_container_tag, build_context.image_registry) |  | ||||||
|     else: |     else: | ||||||
|         print("Skipped") |         print("Skipped") | ||||||
|  |         return True | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| @click.command() | @click.command() | ||||||
| @ -187,11 +182,19 @@ def command(ctx, include, exclude, force_rebuild, extra_build_args, publish_imag | |||||||
|                 container, |                 container, | ||||||
|                 container_build_dir, |                 container_build_dir, | ||||||
|                 container_build_env, |                 container_build_env, | ||||||
|                 dev_root_path, |                 dev_root_path | ||||||
|                 publish_images, |  | ||||||
|                 image_registry |  | ||||||
|             ) |             ) | ||||||
|             process_container(build_context) |             result = process_container(build_context) | ||||||
|  |             if result: | ||||||
|  |                 if publish_images: | ||||||
|  |                     publish_image(container, image_registry) | ||||||
|  |             else: | ||||||
|  |                 print(f"Error running build for {build_context.container}") | ||||||
|  |                 if not opts.o.continue_on_error: | ||||||
|  |                     error_exit("container build failed and --continue-on-error not set, exiting") | ||||||
|  |                     sys.exit(1) | ||||||
|  |                 else: | ||||||
|  |                     print("****** Container Build Error, continuing because --continue-on-error is set") | ||||||
|         else: |         else: | ||||||
|             if opts.o.verbose: |             if opts.o.verbose: | ||||||
|                 print(f"Excluding: {container}") |                 print(f"Excluding: {container}") | ||||||
|  | |||||||
| @ -26,5 +26,4 @@ class BuildContext: | |||||||
|     container_build_dir: Path |     container_build_dir: Path | ||||||
|     container_build_env: Mapping[str,str] |     container_build_env: Mapping[str,str] | ||||||
|     dev_root_path: str |     dev_root_path: str | ||||||
|     publish_images: bool | 
 | ||||||
|     image_registry: str |  | ||||||
|  | |||||||
| @ -26,6 +26,7 @@ import click | |||||||
| from pathlib import Path | from pathlib import Path | ||||||
| from stack_orchestrator.build import build_containers | from stack_orchestrator.build import build_containers | ||||||
| from stack_orchestrator.deploy.webapp.util import determine_base_container | from stack_orchestrator.deploy.webapp.util import determine_base_container | ||||||
|  | from stack_orchestrator.build.build_types import BuildContext | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| @click.command() | @click.command() | ||||||
| @ -65,8 +66,14 @@ def command(ctx, base_container, source_repo, force_rebuild, extra_build_args, t | |||||||
|     container_build_env = build_containers.make_container_build_env(dev_root_path, container_build_dir, debug, |     container_build_env = build_containers.make_container_build_env(dev_root_path, container_build_dir, debug, | ||||||
|                                                                     force_rebuild, extra_build_args) |                                                                     force_rebuild, extra_build_args) | ||||||
| 
 | 
 | ||||||
|     build_containers.process_container(None, base_container, container_build_dir, container_build_env, dev_root_path, quiet, |     build_context_1 = BuildContext( | ||||||
|                                        verbose, dry_run, continue_on_error) |         stack, | ||||||
|  |         base_container, | ||||||
|  |         container_build_dir, | ||||||
|  |         container_build_env, | ||||||
|  |         dev_root_path, | ||||||
|  |     ) | ||||||
|  |     build_containers.process_container(build_context_1) | ||||||
| 
 | 
 | ||||||
|     # Now build the target webapp.  We use the same build script, but with a different Dockerfile and work dir. |     # Now build the target webapp.  We use the same build script, but with a different Dockerfile and work dir. | ||||||
|     container_build_env["CERC_WEBAPP_BUILD_RUNNING"] = "true" |     container_build_env["CERC_WEBAPP_BUILD_RUNNING"] = "true" | ||||||
| @ -80,5 +87,11 @@ def command(ctx, base_container, source_repo, force_rebuild, extra_build_args, t | |||||||
|     else: |     else: | ||||||
|         container_build_env["CERC_CONTAINER_BUILD_TAG"] = tag |         container_build_env["CERC_CONTAINER_BUILD_TAG"] = tag | ||||||
| 
 | 
 | ||||||
|     build_containers.process_container(None, base_container, container_build_dir, container_build_env, dev_root_path, quiet, |     build_context_2 = BuildContext( | ||||||
|                                        verbose, dry_run, continue_on_error) |         stack, | ||||||
|  |         base_container, | ||||||
|  |         container_build_dir, | ||||||
|  |         container_build_env, | ||||||
|  |         dev_root_path, | ||||||
|  |     ) | ||||||
|  |     build_containers.process_container(build_context_2) | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user