aggkit 0.2.7.8356 → 0.2.7.8361
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/bin/aggci +21 -2
- data/lib/aggkit/ci.rb +52 -13
- data/lib/aggkit/env.rb +1 -1
- metadata +1 -1
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA1:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: 94d9152a885e9765d49e1de7170e31c51412200d
         | 
| 4 | 
            +
              data.tar.gz: 10f827f1afa1101deea97ee2fd3e94e02ebdda6e
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: 234f16fc08e0ff76a79343241bee4f431d81c81c62ee7aad5b0228f8f025f51c87b533fceee076c4fcae82b6680ab93c2cafa7d5ae980d84dc2c174f9d92d9e6
         | 
| 7 | 
            +
              data.tar.gz: 39800eb8beba4196a9380407acf2b29ac7436c5321d2b1590b59690b63e1bf6c152732bfc7832917086afe346d76ae269966449d0a9bf767d339f7c6538526f7
         | 
    
        data/Gemfile.lock
    CHANGED
    
    
    
        data/bin/aggci
    CHANGED
    
    | @@ -38,9 +38,18 @@ parser = OptionParser.new do |o| | |
| 38 38 | 
             
                @opts[:clean] = parse_services(services)
         | 
| 39 39 | 
             
              end
         | 
| 40 40 |  | 
| 41 | 
            +
              o.on("--services services", 'list or services to process') do |services|
         | 
| 42 | 
            +
                @opts[:services] = parse_services(services)
         | 
| 43 | 
            +
              end
         | 
| 44 | 
            +
             | 
| 41 45 | 
             
              o.on("--ssh-deploy env", 'ssh') do |env_and_server|
         | 
| 42 46 | 
             
                env, server = env_and_server.strip.split('@')
         | 
| 43 | 
            -
                @opts[:deploy] = {env: env, server: server}
         | 
| 47 | 
            +
                @opts[:deploy] = {env: env, server: server})
         | 
| 48 | 
            +
              end
         | 
| 49 | 
            +
             | 
| 50 | 
            +
              o.on("--ssh-core-deploy env", 'ssh') do |env_and_server|
         | 
| 51 | 
            +
                env, server = env_and_server.strip.split('@')
         | 
| 52 | 
            +
                @opts[:core_deploy] = {env: env, server: server}
         | 
| 44 53 | 
             
              end
         | 
| 45 54 |  | 
| 46 55 | 
             
              o.on("--tag tag=#{@opts[:tag].inspect}", 'Use tag as default tag for images') do |tag|
         | 
| @@ -78,9 +87,19 @@ elsif services = @opts[:clean] | |
| 78 87 | 
             
              exit 0
         | 
| 79 88 |  | 
| 80 89 | 
             
            elsif deploy = @opts[:deploy]
         | 
| 90 | 
            +
              @opts[:services] ||= []
         | 
| 91 | 
            +
              raise "tag not defined" if @opts[:tag].to_s.empty?
         | 
| 92 | 
            +
              raise "stage not defined" if @opts[:stage].to_s.empty?
         | 
| 93 | 
            +
              raise "services not defined" if @opts[:services].empty?
         | 
| 94 | 
            +
              ssh_deploy @opts[:services], deploy[:env], deploy[:server], @opts[:tag], @opts[:stage]
         | 
| 95 | 
            +
              exit 0
         | 
| 96 | 
            +
             | 
| 97 | 
            +
            elsif deploy = @opts[:core_deploy]
         | 
| 98 | 
            +
              @opts[:services] ||= []
         | 
| 81 99 | 
             
              raise "tag not defined" if @opts[:tag].to_s.empty?
         | 
| 82 100 | 
             
              raise "stage not defined" if @opts[:stage].to_s.empty?
         | 
| 83 | 
            -
               | 
| 101 | 
            +
              raise "services not defined" if @opts[:services].empty?
         | 
| 102 | 
            +
              ssh_core_deploy @opts[:services], deploy[:env], deploy[:server], @opts[:tag], @opts[:stage]
         | 
| 84 103 | 
             
              exit 0
         | 
| 85 104 | 
             
            end
         | 
| 86 105 |  | 
    
        data/lib/aggkit/ci.rb
    CHANGED
    
    | @@ -196,6 +196,56 @@ module Aggkit | |
| 196 196 | 
             
                end
         | 
| 197 197 |  | 
| 198 198 | 
             
                def ssh_deploy services, env, sshserver, tag, stage
         | 
| 199 | 
            +
                  with_remote_docker services, env, sshserver, tag, stage do |config, environment|
         | 
| 200 | 
            +
                    config_file = config['config_file'].to_s
         | 
| 201 | 
            +
             | 
| 202 | 
            +
                    execute('docker-compose ps')
         | 
| 203 | 
            +
                    execute('docker-compose pull')
         | 
| 204 | 
            +
             | 
| 205 | 
            +
                    consul = execute('docker ps | grep consul').split(' ').first.strip
         | 
| 206 | 
            +
                    puts "CONSULT ID: #{consul}"
         | 
| 207 | 
            +
             | 
| 208 | 
            +
                    if !config_file.empty?
         | 
| 209 | 
            +
                      execute("docker exec -i #{consul} aggwait -t 20 --consul")
         | 
| 210 | 
            +
                      execute("docker exec -i #{consul} aggconsul --init --override --config - < #{config_file}")
         | 
| 211 | 
            +
                    end
         | 
| 212 | 
            +
             | 
| 213 | 
            +
                    execute('docker-compose up -t 30 -d')
         | 
| 214 | 
            +
                  end
         | 
| 215 | 
            +
                end
         | 
| 216 | 
            +
             | 
| 217 | 
            +
                def ssh_core_deploy services, env, sshserver, tag, stage
         | 
| 218 | 
            +
                  with_remote_docker services, env, sshserver, tag, stage do |config, environment|
         | 
| 219 | 
            +
                    config_file = config['config_file'].to_s
         | 
| 220 | 
            +
             | 
| 221 | 
            +
                    execute('docker-compose ps')
         | 
| 222 | 
            +
                    execute('docker-compose pull')
         | 
| 223 | 
            +
                    execute('docker-compose up -t 30 -d consul')
         | 
| 224 | 
            +
             | 
| 225 | 
            +
                    consul = execute('docker ps | grep consul').split(' ').first.strip
         | 
| 226 | 
            +
                    puts "CONSULT ID: #{consul}"
         | 
| 227 | 
            +
             | 
| 228 | 
            +
                    if !config_file.empty?
         | 
| 229 | 
            +
                      execute("docker exec -i #{consul} aggwait -t 20 --consul")
         | 
| 230 | 
            +
                      execute("docker exec -i #{consul} aggconsul --init --override --config - < #{config_file}")
         | 
| 231 | 
            +
                    end
         | 
| 232 | 
            +
             | 
| 233 | 
            +
                    #echo " * Consul ready"
         | 
| 234 | 
            +
                    #echo " * Updatting database..."
         | 
| 235 | 
            +
                    execute('docker-compose up -t 30 -d db')
         | 
| 236 | 
            +
                    sleep 5
         | 
| 237 | 
            +
                    #echo " * Db ready"
         | 
| 238 | 
            +
                    #echo " * Bootstrapping admin..."
         | 
| 239 | 
            +
                    execute('docker-compose run --rm -T admin /home/app/docker/bootstrap.rb')
         | 
| 240 | 
            +
                    sleep 5
         | 
| 241 | 
            +
                    #echo " * Bootstrapping complete"
         | 
| 242 | 
            +
                    #echo " * Updating all containers..."
         | 
| 243 | 
            +
                    execute('docker-compose up -t 30 -d')
         | 
| 244 | 
            +
                    #echo " * Containers ready"
         | 
| 245 | 
            +
                  end
         | 
| 246 | 
            +
                end
         | 
| 247 | 
            +
             | 
| 248 | 
            +
                def with_remote_docker services, env, sshserver, tag, stage
         | 
| 199 249 | 
             
                  services = [services].flatten
         | 
| 200 250 | 
             
                  log_action "Deploy [#{services.inspect}] tag:#{tag.inspect} stage:#{stage.inspect} to #{sshserver.inspect}"
         | 
| 201 251 | 
             
                  with_ssh sshserver do |sockname|
         | 
| @@ -208,25 +258,14 @@ module Aggkit | |
| 208 258 |  | 
| 209 259 | 
             
                    localid = execute("docker info | grep ID").strip
         | 
| 210 260 |  | 
| 211 | 
            -
                    Aggkit::Env.with_env(envs) do
         | 
| 261 | 
            +
                    Aggkit::Env.with_env(envs) do |environment|
         | 
| 212 262 | 
             
                      remoteid = execute("docker info | grep ID").strip
         | 
| 213 263 |  | 
| 214 264 | 
             
                      if localid == remoteid
         | 
| 215 265 | 
             
                        raise "Can't get access to remote Docker"
         | 
| 216 266 | 
             
                      end
         | 
| 217 267 |  | 
| 218 | 
            -
                       | 
| 219 | 
            -
                      execute('docker-compose pull')
         | 
| 220 | 
            -
             | 
| 221 | 
            -
                      consul = execute('docker ps | grep consul').split(' ').first.strip
         | 
| 222 | 
            -
                      puts "CONSULT ID: #{consul}"
         | 
| 223 | 
            -
             | 
| 224 | 
            -
                      if !config_file.empty?
         | 
| 225 | 
            -
                        execute("docker exec -i #{consul} aggwait -t 20 --consul")
         | 
| 226 | 
            -
                        execute("docker exec -i #{consul} aggconsul --init --override --config - < #{config_file}")
         | 
| 227 | 
            -
                      end
         | 
| 228 | 
            -
             | 
| 229 | 
            -
                      execute('docker-compose up -d')
         | 
| 268 | 
            +
                      yield(env_config, environment)
         | 
| 230 269 |  | 
| 231 270 | 
             
                      services.each do |service|
         | 
| 232 271 | 
             
                        deployed = promotedimage(service, stage, tag)
         | 
    
        data/lib/aggkit/env.rb
    CHANGED