kaiser 0.6.4 → 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 +34 -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
@@ -8,6 +8,12 @@ module Kaiser
|
|
8
8
|
class Cli
|
9
9
|
extend Kaiser::CliOptions
|
10
10
|
|
11
|
+
attr_reader :use_kaiserfile
|
12
|
+
|
13
|
+
def initialize
|
14
|
+
@use_kaiserfile = true
|
15
|
+
end
|
16
|
+
|
11
17
|
def set_config
|
12
18
|
# This is here for backwards compatibility since it can be used in Kaiserfiles.
|
13
19
|
# It would be a good idea to deprecate this and make it more abstract.
|
@@ -19,7 +25,7 @@ module Kaiser
|
|
19
25
|
@out = Config.out
|
20
26
|
@info_out = Config.info_out
|
21
27
|
|
22
|
-
@kaiserfile.validate!
|
28
|
+
@kaiserfile.validate! if @use_kaiserfile
|
23
29
|
end
|
24
30
|
|
25
31
|
# At first I did this in the constructor but the problem with that is Optimist
|
@@ -37,7 +43,7 @@ module Kaiser
|
|
37
43
|
Optimist.options do
|
38
44
|
banner u
|
39
45
|
|
40
|
-
global_opts.each { |o| opt
|
46
|
+
global_opts.each { |o| opt(*o) }
|
41
47
|
end
|
42
48
|
end
|
43
49
|
|
@@ -56,12 +62,12 @@ module Kaiser
|
|
56
62
|
# easily use ARGV.shift to access its own subcommands.
|
57
63
|
ARGV.shift
|
58
64
|
|
59
|
-
Kaiser::Config.load(Dir.pwd)
|
65
|
+
Kaiser::Config.load(Dir.pwd, use_kaiserfile: cmd.use_kaiserfile)
|
60
66
|
|
61
67
|
# We do all this work in here instead of the exe/kaiser file because we
|
62
68
|
# want -h options to output before we check if a Kaiserfile exists.
|
63
69
|
# If we do it in exe/kaiser, people won't be able to check help messages
|
64
|
-
# unless they create a Kaiserfile
|
70
|
+
# unless they create a Kaiserfile first.
|
65
71
|
if opts[:quiet]
|
66
72
|
Config.out = File.open(File::NULL, 'w')
|
67
73
|
Config.info_out = File.open(File::NULL, 'w')
|
@@ -390,6 +396,10 @@ module Kaiser
|
|
390
396
|
@services ||= Config.kaiserfile.services.map { |name, info| Service.new(envname, name, info) }
|
391
397
|
end
|
392
398
|
|
399
|
+
def force_platform
|
400
|
+
Config.kaiserfile.platform || ''
|
401
|
+
end
|
402
|
+
|
393
403
|
def db_port
|
394
404
|
Config.config[:envs][envname][:db_port]
|
395
405
|
end
|
@@ -514,6 +524,19 @@ module Kaiser
|
|
514
524
|
end
|
515
525
|
end
|
516
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
|
+
|
517
540
|
def ensure_setup
|
518
541
|
ensure_env
|
519
542
|
|
@@ -528,15 +551,16 @@ module Kaiser
|
|
528
551
|
"docker run -d
|
529
552
|
--name #{Config.config[:shared_names][:redis]}
|
530
553
|
--network #{Config.config[:networkname]}
|
531
|
-
redis:alpine"
|
554
|
+
redis:7-alpine"
|
532
555
|
)
|
533
556
|
run_if_dead(
|
534
557
|
Config.config[:shared_names][:chrome],
|
535
558
|
"docker run -d
|
536
559
|
-p 5900:5900
|
560
|
+
--shm-size='2g'
|
537
561
|
--name #{Config.config[:shared_names][:chrome]}
|
538
562
|
--network #{Config.config[:networkname]}
|
539
|
-
|
563
|
+
#{selenium_node_image}"
|
540
564
|
)
|
541
565
|
run_if_dead(
|
542
566
|
Config.config[:shared_names][:nginx],
|
@@ -574,7 +598,7 @@ module Kaiser
|
|
574
598
|
|
575
599
|
def container_dead?(container)
|
576
600
|
x = JSON.parse(`docker inspect #{container} 2>/dev/null`)
|
577
|
-
|
601
|
+
x.empty? || x[0]['State']['Running'] == false
|
578
602
|
end
|
579
603
|
|
580
604
|
def if_container_dead(container)
|
@@ -585,14 +609,14 @@ module Kaiser
|
|
585
609
|
|
586
610
|
def create_if_volume_not_exist(vol)
|
587
611
|
x = JSON.parse(`docker volume inspect #{vol} 2>/dev/null`)
|
588
|
-
return unless x.
|
612
|
+
return unless x.empty?
|
589
613
|
|
590
614
|
CommandRunner.run! Config.out, "docker volume create #{vol}"
|
591
615
|
end
|
592
616
|
|
593
617
|
def create_if_network_not_exist(net)
|
594
618
|
x = JSON.parse(`docker inspect #{net} 2>/dev/null`)
|
595
|
-
return unless x.
|
619
|
+
return unless x.empty?
|
596
620
|
|
597
621
|
CommandRunner.run! Config.out, "docker network create #{net}"
|
598
622
|
end
|
@@ -615,7 +639,7 @@ module Kaiser
|
|
615
639
|
|
616
640
|
def killrm(container)
|
617
641
|
x = JSON.parse(`docker inspect #{container} 2>/dev/null`)
|
618
|
-
return if x.
|
642
|
+
return if x.empty?
|
619
643
|
|
620
644
|
CommandRunner.run Config.out, "docker kill #{container}" if x[0]['State'] && x[0]['State']['Running'] == true
|
621
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
|