kaiser 0.0.0 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/README.md +129 -0
- data/exe/kaiser +87 -0
- data/lib/kaiser/after_dotter.rb +23 -0
- data/lib/kaiser/cli.rb +625 -0
- data/lib/kaiser/cli_options.rb +14 -0
- data/lib/kaiser/cmds/attach.rb +23 -0
- data/lib/kaiser/cmds/db_load.rb +29 -0
- data/lib/kaiser/cmds/db_reset.rb +22 -0
- data/lib/kaiser/cmds/db_reset_hard.rb +21 -0
- data/lib/kaiser/cmds/db_save.rb +26 -0
- data/lib/kaiser/cmds/deinit.rb +22 -0
- data/lib/kaiser/cmds/down.rb +21 -0
- data/lib/kaiser/cmds/init.rb +39 -0
- data/lib/kaiser/cmds/login.rb +21 -0
- data/lib/kaiser/cmds/logs.rb +19 -0
- data/lib/kaiser/cmds/root.rb +21 -0
- data/lib/kaiser/cmds/set.rb +73 -0
- data/lib/kaiser/cmds/show.rb +40 -0
- data/lib/kaiser/cmds/shutdown.rb +26 -0
- data/lib/kaiser/cmds/up.rb +43 -0
- data/lib/kaiser/command_runner.rb +50 -0
- data/lib/kaiser/config.rb +81 -0
- data/lib/kaiser/databases/mysql.rb +45 -0
- data/lib/kaiser/databases/postgres.rb +44 -0
- data/lib/kaiser/docker_control.rb +10 -0
- data/lib/kaiser/dotter.rb +21 -0
- data/lib/kaiser/error.rb +14 -0
- data/lib/kaiser/kaiserfile.rb +107 -0
- data/lib/kaiser/plugin.rb +68 -0
- data/lib/kaiser/plugins/database.rb +30 -0
- data/lib/kaiser/plugins/git_submodule.rb +23 -0
- data/lib/kaiser/service.rb +22 -0
- data/lib/kaiser/version.rb +5 -0
- data/lib/kaiser.rb +52 -5
- metadata +178 -17
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 9b21872eac1cbd6823f5dc196633b55a105c921c18d8d4a2a6f559c23f117f1f
|
4
|
+
data.tar.gz: f59edbbde90a7919f1a3a405413e39bf0f1eed3c9f1a45fafca8ed286c1ff062
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3262296ed629a687e945a65f043dda8a31d4d031ca1b86dcb1307f00ff72a7f93ac29fa5b297ea1ef5d17d96994666303cece6625df0c26c936622c7cf6640ec
|
7
|
+
data.tar.gz: 5e4e24279aa2aa24f9f6ecf796e06c1befabef6f40bf2cafb041f823563dba311c29586a4f98bdfc4b5c2c8ea797a1d5869b5cac310a8cfdc81438b7ce8a171a
|
data/README.md
ADDED
@@ -0,0 +1,129 @@
|
|
1
|
+
# Kaiser
|
2
|
+
|
3
|
+
Welcome to Kaiser! Kaiser will mind-control all your monsters and make them even more effective.
|
4
|
+
|
5
|
+
Kaiser lets you define how an application starts, so trying out a web application simply reduces to a `kaiser up`
|
6
|
+
|
7
|
+
## Installation (Traditional)
|
8
|
+
|
9
|
+
1. Download and setup [Docker](https://www.docker.com/get-started)
|
10
|
+
|
11
|
+
2. Add this line to your application's Gemfile:
|
12
|
+
|
13
|
+
```ruby
|
14
|
+
gem 'kaiser', git: "https://github.com/degica/kaiser"
|
15
|
+
```
|
16
|
+
|
17
|
+
3. Execute:
|
18
|
+
|
19
|
+
```$ bundle```
|
20
|
+
|
21
|
+
Or install it yourself as:
|
22
|
+
|
23
|
+
$ gem install specific_install
|
24
|
+
$ gem specific_install -l https://github.com/degica/kaiser
|
25
|
+
|
26
|
+
## Installation (Docker)
|
27
|
+
|
28
|
+
You can install Kaiser as a docker image on your machine too!
|
29
|
+
|
30
|
+
Simply clone the repo and run
|
31
|
+
|
32
|
+
```
|
33
|
+
cd kaiser
|
34
|
+
docker build -t degica/kaiser .
|
35
|
+
```
|
36
|
+
|
37
|
+
And then add the following line to your `.bashrc` or `.bash_profile`
|
38
|
+
|
39
|
+
```
|
40
|
+
alias kaiser='docker run --rm -ti -v /var/run/docker.sock:/var/run/docker.sock -v $HOME/.kaiser:/root/.kaiser -v `pwd`:`pwd` -e CONTEXT_DIR="`pwd`" degica/kaiser'
|
41
|
+
```
|
42
|
+
|
43
|
+
Or if you use fish
|
44
|
+
|
45
|
+
```
|
46
|
+
function kaiser
|
47
|
+
docker run --rm -ti -v /var/run/docker.sock:/var/run/docker.sock -v $HOME/.kaiser:/root/.kaiser -v (pwd):(pwd) -e CONTEXT_DIR=(pwd) degica/kaiser $argv
|
48
|
+
end
|
49
|
+
```
|
50
|
+
|
51
|
+
## Usage
|
52
|
+
|
53
|
+
You'll need a Dockerfile and a Kaiserfile. The Kaiserfile should be placed in the project root directory, with contents like this:
|
54
|
+
|
55
|
+
```ruby
|
56
|
+
# Example Kaiserfile for a Rails app
|
57
|
+
|
58
|
+
dockerfile "Dockerfile.kaiser"
|
59
|
+
|
60
|
+
db "mysql:5.6",
|
61
|
+
port: 3306,
|
62
|
+
data_dir: "/var/lib/mysql",
|
63
|
+
params: "-e MYSQL_ROOT_PASSWORD=test123",
|
64
|
+
commands: ""
|
65
|
+
|
66
|
+
app_params "-e DATABASE_URL=mysql2://root:test123@<%= db_container_name %>"
|
67
|
+
|
68
|
+
expose "9000"
|
69
|
+
db_reset_command "bin/rails db:reset"
|
70
|
+
```
|
71
|
+
|
72
|
+
```dockerfile
|
73
|
+
FROM ruby:alpine
|
74
|
+
|
75
|
+
COPY . /app
|
76
|
+
RUN apk update && apk add build-base
|
77
|
+
RUN gem install bundler
|
78
|
+
RUN bundle install
|
79
|
+
|
80
|
+
EXPOSE "3000"
|
81
|
+
|
82
|
+
CMD ["sh", "-c", "rails -b 0.0.0.0 -p 3000"]
|
83
|
+
```
|
84
|
+
|
85
|
+
Then go to your repo's root folder and go
|
86
|
+
|
87
|
+
```sh
|
88
|
+
bundle exec kaiser init myapp
|
89
|
+
bundle exec kaiser up
|
90
|
+
```
|
91
|
+
|
92
|
+
Once its done, simply
|
93
|
+
|
94
|
+
```sh
|
95
|
+
open http://myapp.lvh.me
|
96
|
+
```
|
97
|
+
|
98
|
+
And enjoy previewing your app!
|
99
|
+
|
100
|
+
## More documentation
|
101
|
+
|
102
|
+
You can find even more documentation in https://tech.degica.com/kaiser.
|
103
|
+
|
104
|
+
If you wish to read a HTML version of this documentation you can go:
|
105
|
+
|
106
|
+
```
|
107
|
+
cd docs
|
108
|
+
bundle install
|
109
|
+
bundle exec weaver
|
110
|
+
```
|
111
|
+
|
112
|
+
|
113
|
+
## Development
|
114
|
+
|
115
|
+
After checking out the repo, run `bundle install` to install dependencies. Then, run `rake spec` to run the tests.
|
116
|
+
|
117
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
118
|
+
|
119
|
+
## Contributing
|
120
|
+
|
121
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/degica/kaiser. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
122
|
+
|
123
|
+
## License
|
124
|
+
|
125
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
126
|
+
|
127
|
+
## Code of Conduct
|
128
|
+
|
129
|
+
Everyone interacting in the Kaiser project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/degica/kaiser/blob/master/CODE_OF_CONDUCT.md).
|
data/exe/kaiser
ADDED
@@ -0,0 +1,87 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
require 'optimist'
|
5
|
+
require 'fileutils'
|
6
|
+
require 'yaml'
|
7
|
+
require 'json'
|
8
|
+
require 'pty'
|
9
|
+
require 'erb'
|
10
|
+
|
11
|
+
require 'kaiser'
|
12
|
+
|
13
|
+
sub_command_strings = Kaiser::SUB_COMMANDS.keys.map(&:to_s)
|
14
|
+
|
15
|
+
Kaiser::SUB_COMMANDS.each { |k, v| Kaiser::Cli.register(k, v) }
|
16
|
+
|
17
|
+
# It was difficult to allow global arguments like -v and -q to be typed both before and after cmds
|
18
|
+
# and still support `kaiser -h` for full help messages and `kaiser subcmd -h` for focused messages.
|
19
|
+
# Putting the global options in an array, using an Optimist::Parser and basically everything up to
|
20
|
+
# the 'end parser hacks' comment are all hacks to marry the above two behaviours.
|
21
|
+
|
22
|
+
global_opts = [
|
23
|
+
[:verbose, "Show Kaiser's debug output", { short: '-v' }],
|
24
|
+
[:quiet, 'Suppress all output', { short: '-q' }]
|
25
|
+
]
|
26
|
+
|
27
|
+
parser = Optimist::Parser.new do
|
28
|
+
version "Kaiser v#{Kaiser::VERSION}"
|
29
|
+
|
30
|
+
banner <<~BANNER
|
31
|
+
#{version}
|
32
|
+
|
33
|
+
Kaiser is a tool to make development a lot easier by defining how an application starts using a \`Kaiserfile\` in the source code's root directory.
|
34
|
+
|
35
|
+
Prerequisites
|
36
|
+
=============
|
37
|
+
|
38
|
+
Install docker on your system and make sure the current user has all the rights required to spin up docker containers.
|
39
|
+
|
40
|
+
Usage
|
41
|
+
=====
|
42
|
+
|
43
|
+
For typical usage you'll want to do the following three commands.
|
44
|
+
|
45
|
+
\`\`\`
|
46
|
+
kaiser init ENV_NAME
|
47
|
+
kaiser up
|
48
|
+
kaiser attach
|
49
|
+
\`\`\`
|
50
|
+
|
51
|
+
This will boot up your application in docker and bind mount your local source directory so you can start doing development. Happy coding!
|
52
|
+
|
53
|
+
If any of these commands are giving you trouble, please run them with the \`-v\` flag set. They will show you what exactly is happening so you can debug.
|
54
|
+
|
55
|
+
Subcommands
|
56
|
+
===========
|
57
|
+
|
58
|
+
- #{Kaiser::SUB_COMMANDS.keys.join("\n- ")}
|
59
|
+
|
60
|
+
Type \`SUB_COMMAND -h\` for help with specific subcommands.
|
61
|
+
|
62
|
+
Global Parameters
|
63
|
+
=================
|
64
|
+
BANNER
|
65
|
+
|
66
|
+
global_opts.each { |o| opt(*o) }
|
67
|
+
end
|
68
|
+
|
69
|
+
commands = sub_command_strings & ARGV
|
70
|
+
|
71
|
+
if commands.empty?
|
72
|
+
Optimist.with_standard_exception_handling parser do
|
73
|
+
raise Optimist::HelpNeeded
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
cmd = commands.first
|
78
|
+
## end parser hacks ##
|
79
|
+
|
80
|
+
begin
|
81
|
+
Kaiser::Cli.run_command(:"#{cmd}", global_opts)
|
82
|
+
rescue Kaiser::Error => e
|
83
|
+
puts ''
|
84
|
+
puts e.message
|
85
|
+
end
|
86
|
+
|
87
|
+
puts ''
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Kaiser
|
4
|
+
# Prints properly after a dotter prints
|
5
|
+
class AfterDotter
|
6
|
+
def initialize(dotter:, channel: $stderr)
|
7
|
+
@channel = channel
|
8
|
+
@dotter = dotter
|
9
|
+
end
|
10
|
+
|
11
|
+
def puts(value)
|
12
|
+
if @dotter.dotted
|
13
|
+
@dotter.dotted = false
|
14
|
+
@channel.puts ''
|
15
|
+
end
|
16
|
+
@channel.puts(value)
|
17
|
+
end
|
18
|
+
|
19
|
+
def flush
|
20
|
+
@channel.flush
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|