Class: Legate::CLI::DeploymentCommands
- Inherits:
-
BaseCommand
- Object
- Thor
- BaseCommand
- Legate::CLI::DeploymentCommands
- Defined in:
- lib/legate/cli/deployment_commands.rb
Overview
CLI commands for generating deployment assets
Constant Summary collapse
- DEFAULT_RUBY_IMAGE =
Default Ruby image if not specified
'ruby:3.2-slim'- DEFAULT_DEPLOYMENT_DIR_NAME =
Default output directory name
'deployment'- DEFAULT_SAMPLE_ENTRYPOINT_PATH =
Default sample entrypoint path
'bin/legate_web_entrypoint.rb'
Instance Method Summary collapse
-
#generate(_directory = '.') ⇒ Object
We might add options for agent service names, memory, cpu later.
Methods inherited from BaseCommand
Instance Method Details
#generate(_directory = '.') ⇒ Object
We might add options for agent service names, memory, cpu later.
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 |
# File 'lib/legate/cli/deployment_commands.rb', line 48 def generate(_directory = '.') # Determine the effective entry point effective_entry_point = if [:generate_sample_entrypoint] [:entry_point] || DEFAULT_SAMPLE_ENTRYPOINT_PATH else [:entry_point] end # Validate entry_point is provided if sample isn't generated unless effective_entry_point say 'Error: --entry-point is required unless --generate-sample-entrypoint is used.', :red exit 1 end deployment_dir = File.([:name]) deployment_dir_basename = File.basename(deployment_dir) gcp_config_name = nil # Store generated config name for final message FileUtils.mkdir_p(deployment_dir) say "Generating deployment assets in #{deployment_dir}...", :green # 0. Generate sample entrypoint if requested (BEFORE generating Dockerfiles) generate_sample_entrypoint_script(effective_entry_point) if [:generate_sample_entrypoint] # 1. Generate Generic Assets (Dockerfile(s), .dockerignore, config.ru) generate_dockerfiles(deployment_dir, effective_entry_point, deployment_dir_basename) generate_dockerignore(deployment_dir) generate_config_ru(deployment_dir, effective_entry_point) # 2. Generate Cloud-Specific Assets case [:cloud] when 'gcp' gcp_config_name = generate_gcp_assets(deployment_dir) when 'aws' generate_aws_assets(deployment_dir) when 'azure' generate_azure_assets(deployment_dir) when 'none' say 'Generated generic Docker assets only.', :yellow else # Should not happen due to Thor's enum check, but good practice say "Unsupported cloud provider: #{[:cloud]}", :red exit 1 end say 'Deployment asset generation complete!', :green say "NOTE: Sample entrypoint generated at '#{effective_entry_point}'.", :yellow if [:generate_sample_entrypoint] if gcp_config_name say "NOTE: A gcloud configuration named '#{gcp_config_name}' was created/updated.", :yellow say ' Activate it using:', :yellow say " gcloud config configurations activate #{gcp_config_name}", :cyan say ' Before running the deployment script.', :yellow end return unless [:cloud] == 'gcp' say "Review the generated files in #{deployment_dir} and the deployment guide:" say " #{File.join(deployment_dir, 'README-GCP-DEPLOYMENT.md')}", :cyan end |