kaiser 0.0.0 → 0.6.4

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: fca5130b0e2499829e856a1c50d3456620ae5d30
4
- data.tar.gz: 454dcd8b92a260abc2071dadcb82446ff3515d04
2
+ SHA256:
3
+ metadata.gz: 9f8047763773bfe748430378babb51a03b464f203653f65b18c914c9dcc0fc5d
4
+ data.tar.gz: f5f4f0965aa9cd5f8b54e5812e8f5810cd96db4140bc5efcfb4483b04394cf81
5
5
  SHA512:
6
- metadata.gz: 6a8015dbe99d1184d4c75aa4599e1334288c40622bb7ad3e973244e387c9c52480cc9a97d80f1398f276fc49145a94b2352b0c8026a0488dd53dec5424f43f03
7
- data.tar.gz: bafeacb6d191595108857bbc33b519e3af18e359e7dfc3df52c2c942a952892ef6cbaa8fd8a5c5261c5486b6d23bf8681c6a6e8d2e8e31c91dba911613d4c87d
6
+ metadata.gz: 2c8500f56e296379d71bbde647cc5c55fdb44079d4ebf149ce2791c1b0aff279c590192baa02953d2b8c87c1a335796b84d410786a032aa0ba23ef059398477c
7
+ data.tar.gz: 1c301bf576a3b1eab3a6fa785b37a9e58afa0c35c2bc9ede6c10bc6bea8a38c87f89fee1817d8dd6938ca32d2d4d667feff7638eeb1f7316b6a203c69be7713c
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