devkitkat 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 8ed6fa28306bb394d6f6128300d955ce43eacd9ca81c6a06abe9ac29ea3232f0
4
+ data.tar.gz: 681ffd8da74c5a2f64e5e118caad29a15a7b99e92c8a7b21da0b9f5329d220ea
5
+ SHA512:
6
+ metadata.gz: a8648ee8040928383c3e5129a4faa1d82233dd54a42cd71f7bf7273c532e3458212877e1f691229ae44172413d646f131bb11b695c6e58ff67774f412f82ee5e
7
+ data.tar.gz: f4f857bd6f21acc44e29ba53e1819638afa3a82bac2691592b7692e3e5a1897a238224280e376c294f55ae6e757939e7a8ff68a515640c75539a5eff2c4ddd67
@@ -0,0 +1,13 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+
10
+ # rspec failure tracking
11
+ .rspec_status
12
+ services
13
+ .devkitkat.yml
@@ -0,0 +1,15 @@
1
+ image: ruby:2.6
2
+
3
+ rspec:
4
+ stage: test
5
+ variables:
6
+ LANG: C.UTF-8
7
+ LC_ALL: C.UTF-8
8
+ before_script:
9
+ - apt-get update
10
+ - apt-get install -y cmake
11
+ - locale
12
+ - locale -a
13
+ script:
14
+ - bin/setup
15
+ - bundle exec rspec
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
@@ -0,0 +1,74 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ In the interest of fostering an open and welcoming environment, we as
6
+ contributors and maintainers pledge to making participation in our project and
7
+ our community a harassment-free experience for everyone, regardless of age, body
8
+ size, disability, ethnicity, gender identity and expression, level of experience,
9
+ nationality, personal appearance, race, religion, or sexual identity and
10
+ orientation.
11
+
12
+ ## Our Standards
13
+
14
+ Examples of behavior that contributes to creating a positive environment
15
+ include:
16
+
17
+ * Using welcoming and inclusive language
18
+ * Being respectful of differing viewpoints and experiences
19
+ * Gracefully accepting constructive criticism
20
+ * Focusing on what is best for the community
21
+ * Showing empathy towards other community members
22
+
23
+ Examples of unacceptable behavior by participants include:
24
+
25
+ * The use of sexualized language or imagery and unwelcome sexual attention or
26
+ advances
27
+ * Trolling, insulting/derogatory comments, and personal or political attacks
28
+ * Public or private harassment
29
+ * Publishing others' private information, such as a physical or electronic
30
+ address, without explicit permission
31
+ * Other conduct which could reasonably be considered inappropriate in a
32
+ professional setting
33
+
34
+ ## Our Responsibilities
35
+
36
+ Project maintainers are responsible for clarifying the standards of acceptable
37
+ behavior and are expected to take appropriate and fair corrective action in
38
+ response to any instances of unacceptable behavior.
39
+
40
+ Project maintainers have the right and responsibility to remove, edit, or
41
+ reject comments, commits, code, wiki edits, issues, and other contributions
42
+ that are not aligned to this Code of Conduct, or to ban temporarily or
43
+ permanently any contributor for other behaviors that they deem inappropriate,
44
+ threatening, offensive, or harmful.
45
+
46
+ ## Scope
47
+
48
+ This Code of Conduct applies both within project spaces and in public spaces
49
+ when an individual is representing the project or its community. Examples of
50
+ representing a project or community include using an official project e-mail
51
+ address, posting via an official social media account, or acting as an appointed
52
+ representative at an online or offline event. Representation of a project may be
53
+ further defined and clarified by project maintainers.
54
+
55
+ ## Enforcement
56
+
57
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
+ reported by contacting the project team at shinya@gitlab.com. All
59
+ complaints will be reviewed and investigated and will result in a response that
60
+ is deemed necessary and appropriate to the circumstances. The project team is
61
+ obligated to maintain confidentiality with regard to the reporter of an incident.
62
+ Further details of specific enforcement policies may be posted separately.
63
+
64
+ Project maintainers who do not follow or enforce the Code of Conduct in good
65
+ faith may face temporary or permanent repercussions as determined by other
66
+ members of the project's leadership.
67
+
68
+ ## Attribution
69
+
70
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
+ available at [http://contributor-covenant.org/version/1/4][version]
72
+
73
+ [homepage]: http://contributor-covenant.org
74
+ [version]: http://contributor-covenant.org/version/1/4/
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source "https://rubygems.org"
2
+
3
+ git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
4
+
5
+ # Specify your gem's dependencies in devkitkat.gemspec
6
+ gemspec
@@ -0,0 +1,74 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ devkitkat (0.1.0)
5
+ activesupport (~> 6.0.0)
6
+ colorize (~> 0.8.1)
7
+ docker-api (~> 1.34.2)
8
+ parallel (~> 1.17.0)
9
+ ruby-progressbar (~> 1.10.1)
10
+
11
+ GEM
12
+ remote: https://rubygems.org/
13
+ specs:
14
+ activesupport (6.0.0)
15
+ concurrent-ruby (~> 1.0, >= 1.0.2)
16
+ i18n (>= 0.7, < 2)
17
+ minitest (~> 5.1)
18
+ tzinfo (~> 1.1)
19
+ zeitwerk (~> 2.1, >= 2.1.8)
20
+ coderay (1.1.2)
21
+ colorize (0.8.1)
22
+ concurrent-ruby (1.1.5)
23
+ diff-lcs (1.3)
24
+ docker-api (1.34.2)
25
+ excon (>= 0.47.0)
26
+ multi_json
27
+ excon (0.67.0)
28
+ i18n (1.6.0)
29
+ concurrent-ruby (~> 1.0)
30
+ method_source (0.9.2)
31
+ minitest (5.12.2)
32
+ multi_json (1.13.1)
33
+ parallel (1.17.0)
34
+ pry (0.12.2)
35
+ coderay (~> 1.1.0)
36
+ method_source (~> 0.9.0)
37
+ pry-nav (0.3.0)
38
+ pry (>= 0.9.10, < 0.13.0)
39
+ rake (10.5.0)
40
+ rspec (3.8.0)
41
+ rspec-core (~> 3.8.0)
42
+ rspec-expectations (~> 3.8.0)
43
+ rspec-mocks (~> 3.8.0)
44
+ rspec-core (3.8.2)
45
+ rspec-support (~> 3.8.0)
46
+ rspec-expectations (3.8.4)
47
+ diff-lcs (>= 1.2.0, < 2.0)
48
+ rspec-support (~> 3.8.0)
49
+ rspec-mocks (3.8.1)
50
+ diff-lcs (>= 1.2.0, < 2.0)
51
+ rspec-support (~> 3.8.0)
52
+ rspec-support (3.8.2)
53
+ rspec-temp_dir (1.1.0)
54
+ rspec (>= 3.0)
55
+ ruby-progressbar (1.10.1)
56
+ thread_safe (0.3.6)
57
+ tzinfo (1.2.5)
58
+ thread_safe (~> 0.1)
59
+ zeitwerk (2.1.10)
60
+
61
+ PLATFORMS
62
+ ruby
63
+
64
+ DEPENDENCIES
65
+ bundler (~> 1.17)
66
+ devkitkat!
67
+ pry (~> 0.12.2)
68
+ pry-nav
69
+ rake (~> 10.0)
70
+ rspec (~> 3.0)
71
+ rspec-temp_dir (~> 1.1.0)
72
+
73
+ BUNDLED WITH
74
+ 1.17.3
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2019 Shinya Maeda
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
@@ -0,0 +1,250 @@
1
+ [![pipeline status](https://gitlab.com/dosuken123/devkitkat-cicd/badges/master/pipeline.svg)](https://gitlab.com/dosuken123/devkitkat-cicd/commits/master)
2
+
3
+ # Devkitkat
4
+
5
+ Devkitkat is a framework for development kits. It lets you
6
+ bootstrap separate services for running a complex application easily.
7
+ This is especially helpful for local development that runs/compiles everything from source code.
8
+
9
+ ## Features
10
+
11
+ This tool provides the following features:
12
+
13
+ - Easy configuration, easiser than docker-compose.
14
+ - Customizable/Flexible scripts for controlling services.
15
+ - Logging command output dy default.
16
+ - Respect the best practice architecture of Cloud Native.
17
+ - Easy to run services in containers (Not available yet).
18
+ - Distrubte machine resources to the cloud VM (Not available yet).
19
+ - No more Makefile for orchestrating services.
20
+
21
+ ## The only config file - `.devkitkat.yml`
22
+
23
+ The only config file `.devkitkat.yml` has to be placed at the root directory where you want to
24
+ download/prepare services. These are available keys.
25
+
26
+ |Key |Type |Required|Default|Description|
27
+ |--- |--- |--- |---|---|
28
+ |`application:` |String |Yes |-|The name of the application that consists of the services|
29
+ |`environment:type:` |String |Yes |-|The type of the environment. One of `local`, `docker` or `cloud`. Default is `local`.|
30
+ |`environment:image:` |String |Yes |-|The docker image. Only effective when `type` is `docker` or `cloud`|
31
+ |`services:` |Hash |Yes |-|The services to run the application|
32
+ |`services:<name>` |Hash |Yes |-|The service name e.g. `rails`, `db`, `redis`|
33
+ |`services:<name>:repo: <value>` |String |No |-|The git URL of the repository|
34
+ |`services:<name>:<key>: <value>` |Hash |No |-|The key and value of the environment variable. e.g. `POSTGRES_PASSWORD: abcdef`. |
35
+ |`groups:` |Hash |No |-|The groups of the services|
36
+ |`groups:<name>: <service-names>` |Hash |No |-|The name of the group and the service names|
37
+
38
+ There are pre-occupied special keys, please do not use these keys in your config file: `services:system`, `services:self`
39
+
40
+ ## Sample `.devkitkat.yml`
41
+
42
+ ```yaml
43
+ application: awesome-app
44
+
45
+ environment:
46
+ type: local
47
+
48
+ services:
49
+ web:
50
+ repo: https://gitlab.com/gitlab-org/gitlab-ce.git
51
+ port: 1234
52
+ db:
53
+ port: 9999
54
+ ```
55
+
56
+ ## Devkitkat image
57
+
58
+ When you run your application with docker containers, you might need to write up
59
+ [Dockerfile](https://docs.docker.com/engine/reference/builder/) and build the image at first,
60
+ this often is time consuming and repeatable task.
61
+ To avoid this cumbersome step, devkitkat provides some useful pre-built machines, which
62
+ works with your application on the fly.
63
+ These images are defined in devkitkat as a ruby script and easy to customize/extend.
64
+ If you don't find useful machines, you can still define it in `services/<name>/dockerfile` directory,
65
+ however, please consider contributing to this repository for the other people who
66
+ would be stuck into the same pitfall/situation.
67
+
68
+ - `Devkitkat::Environment::Image::CommonRubyOnRails`
69
+ - `author`
70
+ - `homepage`
71
+ - etc
72
+
73
+ ## Service structure
74
+
75
+ Each service is stored in the following directories:
76
+
77
+ |Path |Description|
78
+ |--- |---|
79
+ |`services/<name>/src/`| The directory for source code of the service |
80
+ |`services/<name>/script/`| The directory for scripts that controls the service e.g. start, stop, etc.|
81
+ |`services/<name>/data/`| The directory for storing permanent data e.g. database.|
82
+ |`services/<name>/cache/`| The directory for storing ephemeral data to optimize service boot.|
83
+ |`services/<name>/log/`| The directory for logged console output.|
84
+ |`services/<name>/example/`| The directory for extra example scripts that shouldn't be managed in the source repository. |
85
+ |`services/<name>/dockerfile/`| The directory for the docker file that builds the image for the service|
86
+
87
+ ## How to write scripts
88
+
89
+ Since your service's startup command could vary per your application preference,
90
+ you have to define start/stop/configure/etc scripts manually.
91
+
92
+ You can add a script with the following command `devkitkat add-script --name=<name> <target>`.
93
+ It creates a script file at `services/<name>/script/<name>`, and you
94
+ have to code the script details.
95
+
96
+ As the best practice, you should initialize a script dir at first, to do so, execute
97
+ `devkitkat add-script --basic <target>`. It adds the following basic scripts that you'd need
98
+
99
+ - configure/unconfigure ... Configure/Unconfigure the service (Typically, initializes the config file, etc)
100
+ - start/stop ... Start/Stop the service
101
+
102
+ So you might want to execute `devkitkat add-script --basic all` after you've prepared
103
+ .devkitkat.yml. After you write up the commands, you can execute scripts with a command
104
+ like `devkitkat rails configutre` or `devkitkat php start`.
105
+
106
+ You can also define system scripts that does not belong to a specific service.
107
+ There is a handy command `devkitkat add-script <name> system` and it adds a script to `services/system/script` dir.
108
+ . For the system script execution, you can ommit `<target>` from
109
+ the command line e.g. `devkitkat add-test-domain` will work instead of `devkitkat add-test-domain system`.
110
+ As always, log files are stored in `services/system/log` (See more [Service structure](#service-structure))
111
+
112
+ ### Shared script
113
+
114
+ You can create a shared script to be included in service scripts. To do so,
115
+ execute:
116
+
117
+ ```
118
+ devkitkat add-shared-script
119
+ ```
120
+
121
+ This adds `shared` script under `services/system` directory. You can define a
122
+ shared function in the script.
123
+
124
+ To include the shared script, you need to update your service script as the following:
125
+
126
+ ```shell
127
+ #!/bin/bash
128
+ source ${MI_SYSTEM_SCRIPT_SHARED_DIR}
129
+
130
+ # Call a function defiend in the `shared` script
131
+ ```
132
+
133
+ ## Predefined scripts
134
+
135
+ Devkitkat provides predefined scripts that are useful in common development scenarios.
136
+
137
+ |Script name |Available options |Description|
138
+ |--- |--- |---|
139
+ |`clone` |`GIT_DEPTH` ... Speicify git-depth|Clone source code from the `services:<name>:repo:`|
140
+ |`pull` |`GIT_DEPTH` ... Speicify git-depth|Pull source code from the `services:<name>:repo:`|
141
+ |`download` |N/A |Download source code from the `services:<name>:repo:`|
142
+ |`clean` |N/A |Remove all files from `data`, `cache`, `log` and `src` dirs|
143
+ |`docker-build` |`TAG` |Build a docker image|
144
+ |`docker-push` |`REGISTRY` |Push a docker image|
145
+ |`add-user` |`TAG` |Add a user to the current system (It's useful for containerized images)|
146
+ |`add-script` |`--basic` |Add a script to services|
147
+ |`poop` |N/A |:poop:|
148
+
149
+ ## Predefined group names
150
+
151
+ - `all` ... All defined services in `.devkitkat.yml`
152
+
153
+ ## Predefined variables
154
+
155
+ Devkitkat inject these predefined variables into the scripts by default.
156
+
157
+ - `MI_<service>_DIR` ... The root directory path of the service.
158
+ - `MI_<service>_SCRIPT_DIR` ... The script directory path of the service.
159
+ - `MI_<service>_SRC_DIR` ... The source directory path of the service.
160
+ - `MI_<service>_CACHE_DIR` ... The cache directory path of the service.
161
+ - `MI_<service>_DATA_DIR` ... The data directory path of the service.
162
+ - `MI_<service>_LOG_DIR` ... The log directory path of the service.
163
+ - `MI_<service>_EXAMPLE_DIR` ... The example directory path of the service.
164
+ - `MI_<service>_<key>` ... The value of the user-defined variable.
165
+
166
+ NOTE:
167
+ - User-defined variables are injected with the bare name. e.g. If you define
168
+ `VERSION: 1`, then you get the value with `echo $VERSION`. From the other services,
169
+ the variable can be fetched as `MI_<service>_<key>`.
170
+ - `service` is the *uppercase* service *name*. e.g. if the service name is
171
+ `rails`, `MI_RAILS_DIR` is the root directory path of the service.
172
+ - `key` is *uppercase* e.g. `MI_RAILS_HOST`
173
+ - You can also use `SELF` instead of specifying a service name.
174
+ The `SELF` indicates that it's a context specific parameter, for example,
175
+ if you run a script for `workhorse` service, `MI_SELF_DIR` is `services/workhorse`,
176
+ on the other hand, if you run a script for `gitaly` service, `MI_SELF_DIR` is `services/gitaly`.
177
+
178
+ ## How to control services via scripts
179
+
180
+ Basically, command execution follows the below convention.
181
+
182
+ `devkitkat <script-name> <target - service name or group name>`
183
+
184
+ For example, if you want to start `rails` service, your command would look like
185
+
186
+ `devkitkat start rails`
187
+
188
+ , Or, if you want to start all services belong to the `backend` group,
189
+
190
+ `devkitkat start backend`
191
+
192
+ , Or, if you want to pass multiple services, use comma separated service names,
193
+
194
+ `devkitkat start rails,postgres,redis`
195
+
196
+ , Or, if you want to exclude a specific service from a group, use `--exclude` option,
197
+
198
+ `devkitkat start backend --exclude redis`
199
+
200
+ ## Sample commands
201
+
202
+ ```
203
+ devkitkat pull default # Pull source code for the default group
204
+ devkitkat configure default # It configures source code for the default group
205
+ devkitkat start postgresql,redis,gitaly # It starts `postgresql`, `redis` and `gitaly` services.
206
+ devkitkat seed rails # It Seeds for `rails` service
207
+ devkitkat start default # It starts services of the `default` group
208
+ ```
209
+
210
+ ## Options for `devkitkat`
211
+
212
+ - `--path /path/to/the` ... The root directory that contains `.devkitkat.yml` and manage the service dirs.
213
+ - `--variables KEY=VAR` ... The additional environment variables for services.
214
+ - `--exclude <name>` ... The excluded service from the group.
215
+
216
+ Example:
217
+
218
+ `devkitkat start rails --path $HOME/awesome-app-dev-kit/ --variables AWS_CRED=XXXXX`
219
+
220
+ ## Installation
221
+
222
+ $ gem install devkitkat
223
+
224
+ ## Development
225
+
226
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
227
+
228
+ 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).
229
+
230
+ ### Tips
231
+
232
+ **Execute only fast tests**
233
+
234
+ `bundle exec rspec /home/shinya/workspace/devkitkat/spec/devkitkat_spec.rb -t ~slow`
235
+
236
+ **Execute only slow tests**
237
+
238
+ `bundle exec rspec /home/shinya/workspace/devkitkat/spec/devkitkat_spec.rb -t slow`
239
+
240
+ ## Contributing
241
+
242
+ Bug reports and pull requests are welcome on GitHub at https://github.com/dosuken123/devkitkat. 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.
243
+
244
+ ## License
245
+
246
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
247
+
248
+ ## Code of Conduct
249
+
250
+ Everyone interacting in the Devkitkat project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/devkitkat/blob/master/CODE_OF_CONDUCT.md).