kaiser 0.6.3 → 0.7.0
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/README.md +7 -0
- data/lib/kaiser/cli.rb +35 -10
- data/lib/kaiser/cmds/set.rb +5 -0
- data/lib/kaiser/cmds/shutdown.rb +1 -1
- data/lib/kaiser/cmds/up.rb +15 -5
- data/lib/kaiser/config.rb +6 -4
- data/lib/kaiser/kaiserfile.rb +4 -0
- data/lib/kaiser/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 92b3034ab17814ed926d2b9168806132dc548783becdd3b9037b2fefa55b1c9d
|
4
|
+
data.tar.gz: 001e9c5e10b094b349d0a65527da079d483219081e7e8a6e0f2ae0731a2b1d96
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e4e79a8b16f93a34587106cf800d098bbd88a0f26e3a0725fefc01232e2d135a8010c7f728629bf378702070a95c11a437ec7a4486f7c1e881ffc029158a7a61
|
7
|
+
data.tar.gz: 5d4bf821446f25df5f3d6dbb1a30ba0682bcdc7620b60b9acc03c19afd95f919f99da242b6afa873087928d5c7a45522c400125b0407696485e9bcbe6fcaf7c9
|
data/README.md
CHANGED
@@ -31,6 +31,7 @@ Simply clone the repo and run
|
|
31
31
|
|
32
32
|
```
|
33
33
|
cd kaiser
|
34
|
+
bundle
|
34
35
|
docker build -t degica/kaiser .
|
35
36
|
```
|
36
37
|
|
@@ -48,6 +49,12 @@ function kaiser
|
|
48
49
|
end
|
49
50
|
```
|
50
51
|
|
52
|
+
Confirm it is working by running
|
53
|
+
|
54
|
+
```
|
55
|
+
kaiser -h
|
56
|
+
```
|
57
|
+
|
51
58
|
## Usage
|
52
59
|
|
53
60
|
You'll need a Dockerfile and a Kaiserfile. The Kaiserfile should be placed in the project root directory, with contents like this:
|
data/lib/kaiser/cli.rb
CHANGED
@@ -1,12 +1,19 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require 'kaiser/command_runner'
|
4
|
+
require 'active_support/core_ext/object/blank'
|
4
5
|
|
5
6
|
module Kaiser
|
6
7
|
# The commandline
|
7
8
|
class Cli
|
8
9
|
extend Kaiser::CliOptions
|
9
10
|
|
11
|
+
attr_reader :use_kaiserfile
|
12
|
+
|
13
|
+
def initialize
|
14
|
+
@use_kaiserfile = true
|
15
|
+
end
|
16
|
+
|
10
17
|
def set_config
|
11
18
|
# This is here for backwards compatibility since it can be used in Kaiserfiles.
|
12
19
|
# It would be a good idea to deprecate this and make it more abstract.
|
@@ -18,7 +25,7 @@ module Kaiser
|
|
18
25
|
@out = Config.out
|
19
26
|
@info_out = Config.info_out
|
20
27
|
|
21
|
-
@kaiserfile.validate!
|
28
|
+
@kaiserfile.validate! if @use_kaiserfile
|
22
29
|
end
|
23
30
|
|
24
31
|
# At first I did this in the constructor but the problem with that is Optimist
|
@@ -36,7 +43,7 @@ module Kaiser
|
|
36
43
|
Optimist.options do
|
37
44
|
banner u
|
38
45
|
|
39
|
-
global_opts.each { |o| opt
|
46
|
+
global_opts.each { |o| opt(*o) }
|
40
47
|
end
|
41
48
|
end
|
42
49
|
|
@@ -55,12 +62,12 @@ module Kaiser
|
|
55
62
|
# easily use ARGV.shift to access its own subcommands.
|
56
63
|
ARGV.shift
|
57
64
|
|
58
|
-
Kaiser::Config.load(Dir.pwd)
|
65
|
+
Kaiser::Config.load(Dir.pwd, use_kaiserfile: cmd.use_kaiserfile)
|
59
66
|
|
60
67
|
# We do all this work in here instead of the exe/kaiser file because we
|
61
68
|
# want -h options to output before we check if a Kaiserfile exists.
|
62
69
|
# If we do it in exe/kaiser, people won't be able to check help messages
|
63
|
-
# unless they create a Kaiserfile
|
70
|
+
# unless they create a Kaiserfile first.
|
64
71
|
if opts[:quiet]
|
65
72
|
Config.out = File.open(File::NULL, 'w')
|
66
73
|
Config.info_out = File.open(File::NULL, 'w')
|
@@ -389,6 +396,10 @@ module Kaiser
|
|
389
396
|
@services ||= Config.kaiserfile.services.map { |name, info| Service.new(envname, name, info) }
|
390
397
|
end
|
391
398
|
|
399
|
+
def force_platform
|
400
|
+
Config.kaiserfile.platform || ''
|
401
|
+
end
|
402
|
+
|
392
403
|
def db_port
|
393
404
|
Config.config[:envs][envname][:db_port]
|
394
405
|
end
|
@@ -513,6 +524,19 @@ module Kaiser
|
|
513
524
|
end
|
514
525
|
end
|
515
526
|
|
527
|
+
def selenium_node_image
|
528
|
+
return ENV['OVERRIDE_SELENIUM_NODE_IMAGE'] unless ENV['OVERRIDE_SELENIUM_NODE_IMAGE'].nil?
|
529
|
+
|
530
|
+
if RUBY_PLATFORM.start_with?('arm64') || RUBY_PLATFORM.start_with?('aarch64')
|
531
|
+
# use the seleniarm image because its more stable in arm procs
|
532
|
+
# somehow the x64 image does not do well under qemu under arm
|
533
|
+
return 'seleniarm/standalone-chromium'
|
534
|
+
end
|
535
|
+
|
536
|
+
# default to x64 image
|
537
|
+
'selenium/standalone-chrome-debug'
|
538
|
+
end
|
539
|
+
|
516
540
|
def ensure_setup
|
517
541
|
ensure_env
|
518
542
|
|
@@ -527,15 +551,16 @@ module Kaiser
|
|
527
551
|
"docker run -d
|
528
552
|
--name #{Config.config[:shared_names][:redis]}
|
529
553
|
--network #{Config.config[:networkname]}
|
530
|
-
redis:alpine"
|
554
|
+
redis:7-alpine"
|
531
555
|
)
|
532
556
|
run_if_dead(
|
533
557
|
Config.config[:shared_names][:chrome],
|
534
558
|
"docker run -d
|
535
559
|
-p 5900:5900
|
560
|
+
--shm-size='2g'
|
536
561
|
--name #{Config.config[:shared_names][:chrome]}
|
537
562
|
--network #{Config.config[:networkname]}
|
538
|
-
|
563
|
+
#{selenium_node_image}"
|
539
564
|
)
|
540
565
|
run_if_dead(
|
541
566
|
Config.config[:shared_names][:nginx],
|
@@ -573,7 +598,7 @@ module Kaiser
|
|
573
598
|
|
574
599
|
def container_dead?(container)
|
575
600
|
x = JSON.parse(`docker inspect #{container} 2>/dev/null`)
|
576
|
-
|
601
|
+
x.empty? || x[0]['State']['Running'] == false
|
577
602
|
end
|
578
603
|
|
579
604
|
def if_container_dead(container)
|
@@ -584,14 +609,14 @@ module Kaiser
|
|
584
609
|
|
585
610
|
def create_if_volume_not_exist(vol)
|
586
611
|
x = JSON.parse(`docker volume inspect #{vol} 2>/dev/null`)
|
587
|
-
return unless x.
|
612
|
+
return unless x.empty?
|
588
613
|
|
589
614
|
CommandRunner.run! Config.out, "docker volume create #{vol}"
|
590
615
|
end
|
591
616
|
|
592
617
|
def create_if_network_not_exist(net)
|
593
618
|
x = JSON.parse(`docker inspect #{net} 2>/dev/null`)
|
594
|
-
return unless x.
|
619
|
+
return unless x.empty?
|
595
620
|
|
596
621
|
CommandRunner.run! Config.out, "docker network create #{net}"
|
597
622
|
end
|
@@ -614,7 +639,7 @@ module Kaiser
|
|
614
639
|
|
615
640
|
def killrm(container)
|
616
641
|
x = JSON.parse(`docker inspect #{container} 2>/dev/null`)
|
617
|
-
return if x.
|
642
|
+
return if x.empty?
|
618
643
|
|
619
644
|
CommandRunner.run Config.out, "docker kill #{container}" if x[0]['State'] && x[0]['State']['Running'] == true
|
620
645
|
CommandRunner.run Config.out, "docker rm #{container}" if x[0]['State']
|
data/lib/kaiser/cmds/set.rb
CHANGED
data/lib/kaiser/cmds/shutdown.rb
CHANGED
data/lib/kaiser/cmds/up.rb
CHANGED
@@ -28,14 +28,24 @@ module Kaiser
|
|
28
28
|
end
|
29
29
|
end
|
30
30
|
|
31
|
+
def build_cmd
|
32
|
+
platform_args = ''
|
33
|
+
platform_args = "--platform=#{force_platform}" unless force_platform.empty?
|
34
|
+
build_args = docker_build_args.map { |k, v| "--build-arg #{k}=#{v}" }
|
35
|
+
[
|
36
|
+
'docker build',
|
37
|
+
"-t kaiser:#{envname}-#{current_branch}",
|
38
|
+
"-f #{tmp_dockerfile_name} #{Config.work_dir}",
|
39
|
+
platform_args,
|
40
|
+
build_args.join(' ').to_s
|
41
|
+
]
|
42
|
+
end
|
43
|
+
|
31
44
|
def setup_app
|
32
45
|
Config.info_out.puts 'Setting up application'
|
33
46
|
File.write(tmp_dockerfile_name, docker_file_contents)
|
34
|
-
|
35
|
-
CommandRunner.run! Config.out, "
|
36
|
-
-t kaiser:#{envname}-#{current_branch}
|
37
|
-
-f #{tmp_dockerfile_name} #{Config.work_dir}
|
38
|
-
#{build_args.join(' ')}"
|
47
|
+
|
48
|
+
CommandRunner.run! Config.out, build_cmd.join("\n\t")
|
39
49
|
FileUtils.rm(tmp_dockerfile_name)
|
40
50
|
end
|
41
51
|
end
|
data/lib/kaiser/config.rb
CHANGED
@@ -12,7 +12,7 @@ module Kaiser
|
|
12
12
|
:kaiserfile,
|
13
13
|
:config
|
14
14
|
|
15
|
-
def load(work_dir)
|
15
|
+
def load(work_dir, use_kaiserfile: true)
|
16
16
|
@work_dir = work_dir
|
17
17
|
@config_dir = "#{ENV['HOME']}/.kaiser"
|
18
18
|
|
@@ -20,7 +20,6 @@ module Kaiser
|
|
20
20
|
|
21
21
|
FileUtils.mkdir_p @config_dir
|
22
22
|
@config_file = "#{@config_dir}/config.yml"
|
23
|
-
@kaiserfile = Kaiserfile.new("#{@work_dir}/Kaiserfile")
|
24
23
|
|
25
24
|
@config = {
|
26
25
|
envnames: {},
|
@@ -39,8 +38,11 @@ module Kaiser
|
|
39
38
|
|
40
39
|
load_config
|
41
40
|
|
42
|
-
|
43
|
-
|
41
|
+
if use_kaiserfile
|
42
|
+
@kaiserfile = Kaiserfile.new("#{@work_dir}/Kaiserfile")
|
43
|
+
alt_kaiserfile = "#{ENV['HOME']}/kaiserfiles/Kaiserfile.#{@config[:envnames][work_dir]}"
|
44
|
+
@kaiserfile = Kaiserfile.new(alt_kaiserfile) if File.exist?(alt_kaiserfile)
|
45
|
+
end
|
44
46
|
|
45
47
|
@config
|
46
48
|
end
|
data/lib/kaiser/kaiserfile.rb
CHANGED
data/lib/kaiser/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: kaiser
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.7.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- David Siaw
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-05-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -198,7 +198,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
198
198
|
- !ruby/object:Gem::Version
|
199
199
|
version: '0'
|
200
200
|
requirements: []
|
201
|
-
rubygems_version: 3.
|
201
|
+
rubygems_version: 3.3.26
|
202
202
|
signing_key:
|
203
203
|
specification_version: 4
|
204
204
|
summary: Manage your monsters
|