Class: Nvoi::Cli::Deploy::Command

Inherits:
Object
  • Object
show all
Defined in:
lib/nvoi/cli/deploy/command.rb

Overview

Command orchestrates the full deployment process

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ Command

Returns a new instance of Command.



8
9
10
11
# File 'lib/nvoi/cli/deploy/command.rb', line 8

def initialize(options)
  @options = options
  @log = Nvoi.logger
end

Instance Method Details

#runObject



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/nvoi/cli/deploy/command.rb', line 13

def run
  @log.info "Deploy CLI %s", VERSION

  # Load configuration
  config_path = resolve_config_path
  working_dir = @options[:dir] || "."
  dockerfile_path = @options[:dockerfile_path] || File.join(working_dir, "Dockerfile")

  @config = Utils::ConfigLoader.load(config_path)

  # Apply branch override if specified
  apply_branch_override if @options[:branch]

  # Initialize cloud provider
  @provider = External::Cloud.for(@config)
  validate_provider_config

  @log.info "Using %s Cloud provider", @config.provider_name
  @log.info "Starting deployment"
  @log.separator

  # Step 1: Provision infrastructure (network, servers)
  main_server_ip = provision_infrastructure

  # Step 2: Configure Cloudflare tunnels
  tunnels = configure_tunnels

  # Step 3: Deploy application
  deploy_application(main_server_ip, tunnels, working_dir)

  # Success
  @log.separator
  @log.success "Deployment complete"

  # Log service URLs
  tunnels.each do |tunnel|
    @log.info "Service %s: https://%s", tunnel.service_name, tunnel.hostname
  end
end