pike 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 7fb975855d3b151edfc497b4b44b362c7b8005f6
4
+ data.tar.gz: 046f89d3bd1d0885d18e5f8c77a78ce5937f3d95
5
+ SHA512:
6
+ metadata.gz: 228f43c695a7a628c0f56eafe55bace606b7d04df0ab92ce333345aa4b8a79945badf240db5d724bb981da3864cb593454172179e9d50333e65d42aa290a5dac
7
+ data.tar.gz: 35577733d5f61f2ca7432f5e982e5db93cbaac2e65796f91d7821d341d78697ec8cc378293c971c85e73036e1666a3f5afa394762df81f8d5ca9baa7fe266e24
data/.gitignore ADDED
@@ -0,0 +1,18 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ coverage
6
+ InstalledFiles
7
+ lib/bundler/man
8
+ pkg
9
+ rdoc
10
+ spec/reports
11
+ test/tmp
12
+ test/version_tmp
13
+ tmp
14
+
15
+ # YARD artifacts
16
+ .yardoc
17
+ _yardoc
18
+ doc/
data/.travis.yml ADDED
@@ -0,0 +1,12 @@
1
+ branches:
2
+ only:
3
+ - 'master'
4
+
5
+ language: ruby
6
+
7
+ rvm:
8
+ - 2.1.0
9
+ - 2.0.0
10
+ - 1.9.3
11
+
12
+ script: "./script/build"
data/Gemfile ADDED
@@ -0,0 +1,8 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in pike.gemspec
4
+ gemspec
5
+
6
+ group :testing do
7
+ gem 'coveralls', require: false
8
+ end
data/Gemfile.lock ADDED
@@ -0,0 +1,52 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ pike (0.0.1)
5
+ net-scp (~> 1.0)
6
+ net-ssh (~> 2.1)
7
+ net-ssh-shell (~> 0.2)
8
+ steps (~> 1.1)
9
+
10
+ GEM
11
+ remote: https://rubygems.org/
12
+ specs:
13
+ colored (1.2)
14
+ coveralls (0.7.0)
15
+ multi_json (~> 1.3)
16
+ rest-client
17
+ simplecov (>= 0.7)
18
+ term-ansicolor
19
+ thor
20
+ docile (1.1.2)
21
+ highline (1.6.20)
22
+ mime-types (2.0)
23
+ multi_json (1.8.4)
24
+ net-scp (1.0.4)
25
+ net-ssh (>= 1.99.1)
26
+ net-ssh (2.1.4)
27
+ net-ssh-shell (0.2.0)
28
+ net-ssh (~> 2.1.0)
29
+ rake (10.1.1)
30
+ rest-client (1.6.7)
31
+ mime-types (>= 1.16)
32
+ simplecov (0.8.2)
33
+ docile (~> 1.1.0)
34
+ multi_json
35
+ simplecov-html (~> 0.8.0)
36
+ simplecov-html (0.8.0)
37
+ steps (1.1.3)
38
+ colored (>= 1.2)
39
+ highline (>= 1.6)
40
+ term-ansicolor (1.2.2)
41
+ tins (~> 0.8)
42
+ thor (0.18.1)
43
+ tins (0.13.1)
44
+
45
+ PLATFORMS
46
+ ruby
47
+
48
+ DEPENDENCIES
49
+ bundler (~> 1.5)
50
+ coveralls
51
+ pike!
52
+ rake (~> 10.1)
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2013 Benjamin Kammerl aka phortx
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
6
+ this software and associated documentation files (the "Software"), to deal in
7
+ the Software without restriction, including without limitation the rights to
8
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9
+ the Software, and to permit persons to whom the Software is furnished to do so,
10
+ subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ 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, FITNESS
17
+ FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18
+ COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19
+ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20
+ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/Pikefile.example ADDED
@@ -0,0 +1,103 @@
1
+ # The name of the app to build
2
+ var name: 'example'
3
+
4
+ env :production do
5
+ # Hostname to deploy on
6
+ var host: 'example.com'
7
+
8
+ # SSH User to login with
9
+ var user: 'sheldon'
10
+
11
+ # If the user doesn't have any writing permissions to the directory where the app is deployed,
12
+ # set to true and pike will use sudo
13
+ var use_sudo: true
14
+
15
+ # Destination path where to deploy the app
16
+ var deploy_to: '/var/www/example.com/'
17
+
18
+
19
+ lifecycle do
20
+ # Clones the git repo in a temporary directory
21
+ run :clone, {
22
+ repository: "https://github.com/example/example.git",
23
+ branch: :master
24
+ }
25
+
26
+
27
+ # Runs `git submodules init`
28
+ run :submodules
29
+
30
+
31
+ # Runs `bundle install --without testing production`
32
+ run :bundle, {
33
+ without: [:testing, :production]
34
+ }
35
+
36
+
37
+ # Runs the rspec suite and cancel the build if it doesn't proceed
38
+ run :rspec
39
+
40
+
41
+ # Runs `RAILS_ENV=development RAILS_GROUPS=assets bundle exec rake assets:precompile`
42
+ run :assets, {
43
+ rails_groups: :assets,
44
+ rails_env: :development
45
+ }
46
+
47
+
48
+ # Remove all files and dirs which are not neccessary for production operation
49
+ run :reduce, {
50
+ clean: [
51
+ 'coverage',
52
+ 'spec',
53
+ '.gitignore',
54
+ 'Rbafile',
55
+ 'Guardfile',
56
+ 'db/*.sqlite3',
57
+ 'tmp/sessions',
58
+ 'tmp/cache',
59
+ 'README.md',
60
+ '.gitignore',
61
+ '.git',
62
+ '.rspec',
63
+ '.gitmodules'
64
+ ]
65
+ }
66
+
67
+ # Builds the .rba file and removes the temporary directory
68
+ run :build
69
+
70
+
71
+ # Uploads the .rba file to the remote machine and deploys it there by creating new release
72
+ # directory and extract the archive there, creates symlinks for the public directory too.
73
+ run :deploy
74
+
75
+
76
+ # Creates symlinks for all shared files on the remote machine
77
+ run :symlink_shared, {
78
+ files: ['config/config.yml']
79
+ }
80
+
81
+
82
+ # Creates symlinks for all executables on the remote machine
83
+ run :symlink_executables, {
84
+ files: ['run.sh']
85
+ }
86
+
87
+
88
+ # Runs `bundle install --without testing development assets --deployment`
89
+ run :bundle_deployment, {
90
+ without: [:testing, :development, :assets]
91
+ }
92
+
93
+
94
+ # Migrates the database (or creates a new one)
95
+ run :migrate
96
+
97
+
98
+ # Remove older revisions except the current and one more. And removes the .rba file.
99
+ run :cleanup, {
100
+ keep_releases: 1
101
+ }
102
+ end
103
+ end
data/README.md ADDED
@@ -0,0 +1,139 @@
1
+ # PIKE >> Intelligent Deployment
2
+
3
+ [![Build Status](https://travis-ci.org/phortx/pike.png?branch=master)](https://travis-ci.org/phortx/pike)
4
+ [![Coverage Status](https://coveralls.io/repos/phortx/pike/badge.png)](https://coveralls.io/r/phortx/pike)
5
+ [![Dependency Status](https://gemnasium.com/phortx/pike.png)](https://gemnasium.com/phortx/pike)
6
+ [![Code Climate](https://codeclimate.com/github/phortx/pike.png)](https://codeclimate.com/github/phortx/pike)
7
+
8
+
9
+ **Warning:** This is an very very early state of development and the codebase is really ugly and cluttered. Don't use it yet.
10
+
11
+
12
+
13
+
14
+ ## What is pike?
15
+ Pike is a smart deployment automation system built to make your life easier.
16
+
17
+ Based on my experiences made with vlad, capistrano and manual deployments, I've build a deployment automation, which is easier to use and supports sudo, ssh, powerful configuration and very flexible build processes. Additionally I've combined it with the result of my Ruby Archives experiment. So pike doesn't clone the git repository on the production machine, rather then cloning it locally, run the build, packs everything neccessary in a single ruby archive file, compresses it and sends it to the production machine to deploy that file in a very clean way. That reduces the amount of depdencies required on the server, files on the server and the temptation to change files in the repo to quick patch something.
18
+
19
+ The goal of pike is to ship a smart but easy to use deployment automation system which makes deployments fun and your life easier.
20
+
21
+
22
+
23
+
24
+ ## Features
25
+ * Custom build process: Create your own lifecycle with the tasks you need.
26
+ * Huge arsenal of builtin tasks.
27
+ * Nice verbose logging and a very fancy console output format.
28
+ * Reduces your app code to the required minimum, packs it in one file, compresses it and sends that one file to the server
29
+ * Release management
30
+ * Automated Rollback if something breaks
31
+ * Based on SSH
32
+ * local and remote tasks
33
+ * Integrates well with ...
34
+ * sudo
35
+ * your .ssh/config
36
+ * rvm
37
+ * rails
38
+ * Built to make you happy. And me.
39
+
40
+
41
+
42
+
43
+ ## Usage
44
+ 1. Read the [Pikefile documentation](https://github.com/phortx/pike/wiki/Pikefile)
45
+ 2. Setup a Pikefile
46
+ 3. Run <code>pike your_environment setup</code> which will setup the infrastructure initially on your server
47
+ 4. After that you can deploy the app via <code>pike your_environment</code>
48
+
49
+
50
+
51
+
52
+ ## Documentation
53
+ * [Pikefile](https://github.com/phortx/pike/wiki/Pikefile)
54
+ * [Buildint tasks](https://github.com/phortx/pike/wiki/Tasks)
55
+ * [Write your own Tasks](https://github.com/phortx/pike/wiki/Write-Tasks)
56
+
57
+
58
+
59
+
60
+ ## Contribution
61
+ 1. Fork via the github fork button
62
+ 2. Clone your fork to your local machine
63
+ 3. Run script/setup
64
+ 4. Run bundle exec rspec spec/ and see how everything passes (green)
65
+ 5. Make your changes
66
+ 6. Run bundle exec rspec spec/ and repeat 5. and 6. until everything passes
67
+ 7. Commit
68
+ 8. Repeat 5. - 7. until you're done
69
+ 9. git push
70
+ 10. Open a pull request
71
+ 11. Get a beer and wait for the merge
72
+
73
+
74
+
75
+
76
+ ## Thanks to
77
+ * Vlad and Capistrano for the idea, a good implementation and the (good and bad) experiences I've made by using them.
78
+ * sshkit and net-ssh-shell for the experiences I've gathered with them about Net::SSH
79
+ * Captain Christopher Pike (Star Trek) for inspiring me to the project name. Or should I thank Gene Roddenberry?
80
+
81
+
82
+
83
+
84
+ ## FAQ
85
+ ### Why did you built another deployment automation while there are capistrano and vlad out there? Why are you competing against capistrano/vlad/whatever?
86
+ I want you to understand, that I don't want to replace capistrano or vlad or other deployment
87
+ automations with pike. I've used capistrano and vlad and they do a good job, the huge user base of
88
+ both projects confirm that.
89
+
90
+ The issue is, both capistrano and vlad don't meet my requirements and are useless for my deployment
91
+ style and use case. If I would use one of them, I had to write many complex recipes. Instead of
92
+ writing those recipipes, I also could write my own deployment automation, which has the features
93
+ I need. So I did. My goal for pike is to create a smart deployment automation with fancy and clear
94
+ output, which integrated well with some mainstream ruby technologies (rails, rvm) and sudo and which
95
+ makes your life easier and deployments more fun.
96
+
97
+ I have no problem with capistrano, vlad or other deployment automations, I just wanted to create my
98
+ own one, which meets my requirements. That's it :)
99
+
100
+ If you think, that pike doesn't help you, feel free to use any other software you like, I'll not
101
+ judge you. Software is a tool which should make your life easier and I don't like the way of
102
+ thinking like some developers out there do while arguing against me, that their product is better
103
+ then another one. That's like the Windows vs Mac vs Linux discussion, which I really hate. The point
104
+ is: Everything has it's strengths and weaks. Use those tools that help you to get your work done
105
+ and be happy. And Linux is the best one. ;)
106
+
107
+
108
+
109
+ ### WTF is a .rba file?
110
+ It's a ruby archive. A file format I've invented for pike. Ok to be honest, just a file extention
111
+ I've inveted, since is a boring .tar.gz file containing production optimized ruby code.
112
+
113
+ **The idea behind is simple:** Instead if cloning all your repository code to the production server,
114
+ which contains a lot of clutter like documentation, rspec, coverage reports, git files, IDE files,
115
+ whatever, pike clones the project on your develop machine, removes all the clutter from the
116
+ directory, runs some tasks like precompiling the assets and then packs everything (including the
117
+ compiled assets) without the clutter in a single compressed file, which is sent to the server.
118
+
119
+ **The advantages:** Your file transfer to your server is faster and your project requires less disk
120
+ space there while it also hides the code from you, which makes it harder to do code changes on the
121
+ production machine to fix something. It forces you to do changes on your development machine and
122
+ redeploy. Additionally your project directory on the server is very clean so you can focus on the
123
+ important stuff like config files.
124
+
125
+ **The disadvantages:** None ;)
126
+
127
+
128
+
129
+
130
+ ## Licence
131
+ pike is licensed under the MIT License.
132
+
133
+ Copyright (c) 2013 Benjamin Kammerl aka phortx
134
+
135
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
136
+
137
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
138
+
139
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require 'bundler/gem_tasks'
data/bin/pike ADDED
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'pike'
@@ -0,0 +1,56 @@
1
+ module Pike
2
+ module DSL
3
+ class Environment
4
+ ##
5
+ ## Executes a block with DSL commands
6
+ ##
7
+
8
+ def self.load(env, &block)
9
+ dsl = new
10
+ dsl.load env, &block
11
+ dsl
12
+ end
13
+
14
+ def load(env = nil, &block)
15
+ @env = env if env
16
+ instance_eval &block
17
+ end
18
+
19
+
20
+ ##
21
+ ## DSL command to define the lifecycle
22
+ ##
23
+
24
+ def lifecycle(&block)
25
+ load &block
26
+ end
27
+
28
+
29
+ ##
30
+ ## DSL command to add a task to the lifecycle
31
+ ##
32
+
33
+ def run(name, params = {})
34
+ @env.add_task name, params
35
+ end
36
+
37
+
38
+ ##
39
+ ## DSL command to set variables
40
+ ##
41
+
42
+ def var(vars = {})
43
+ @env.set_var vars
44
+ end
45
+
46
+
47
+ ##
48
+ ## DSL command to get the value of a variable
49
+ ##
50
+
51
+ def get(key)
52
+ @env.get_var vars
53
+ end
54
+ end
55
+ end
56
+ end
@@ -0,0 +1,51 @@
1
+ module Pike
2
+ module DSL
3
+ class Pikefile
4
+ ##
5
+ ## Loads a Pike DSL basef file
6
+ ##
7
+
8
+ def self.load(filename)
9
+ dsl = new
10
+ dsl.instance_eval File.read(filename), filename
11
+ dsl
12
+ end
13
+
14
+
15
+ ##
16
+ ## DSL Function to set variables
17
+ ##
18
+
19
+ def var(vars = {})
20
+ Main.set_var vars
21
+ end
22
+
23
+
24
+ ##
25
+ ## DSL Function to get a variables values
26
+ ##
27
+
28
+ def get(key)
29
+ Main.get_var key
30
+ end
31
+
32
+
33
+ ##
34
+ ## DSL Function to add a task
35
+ ##
36
+
37
+ def task(name, &block)
38
+ Main.add_task name, &block
39
+ end
40
+
41
+
42
+ ##
43
+ ## DSL Function to add a environment
44
+ ##
45
+
46
+ def env(name, &block)
47
+ Main.add_env name, &block
48
+ end
49
+ end
50
+ end
51
+ end
@@ -0,0 +1,101 @@
1
+ module Pike
2
+ module DSL
3
+ class Task
4
+ ##
5
+ ## Executes a block with DSL commands
6
+ ##
7
+
8
+ def self.load(task, &block)
9
+ dsl = new
10
+ dsl.load task, &block
11
+ dsl
12
+ end
13
+
14
+ def load(task = nil, &block)
15
+ @task = task if task
16
+ instance_eval &block
17
+ end
18
+
19
+
20
+ ##
21
+ ## DSL command to run a command on the remote machine
22
+ ##
23
+
24
+ def remote(cmd, vars = {})
25
+ Tasks::Command.new(@task, :remote, cmd, vars).run(@task.current_env)
26
+ end
27
+
28
+
29
+ ##
30
+ ## DSL command to run a command on the local machine
31
+ ##
32
+
33
+ def local(cmd, vars = {})
34
+ Tasks::Command.new(@task, :local, cmd, vars).run(@task.current_env)
35
+ end
36
+
37
+
38
+ ##
39
+ ## DSL command to run another task
40
+ ##
41
+
42
+ def exec(task)
43
+ @task.run_tasktask
44
+ end
45
+
46
+
47
+ ##
48
+ ## DSL command to build the rba file
49
+ ##
50
+
51
+ def build_rba
52
+ "!BUILD_RBA"
53
+ end
54
+
55
+
56
+ ##
57
+ ## DSL command to upload a file from local machine to remote machine
58
+ ##
59
+
60
+ def upload(local, remote)
61
+ local "!SCP #{local} #{remote}"
62
+ end
63
+
64
+
65
+ ##
66
+ ## DSL command to get the value of a variable
67
+ ##
68
+
69
+ def get(key)
70
+ @task.get_var key
71
+ end
72
+
73
+
74
+ ##
75
+ ## DSL command to get the value of a variable
76
+ ##
77
+
78
+ def param(key, default = nil)
79
+ @task.get_param key, default
80
+ end
81
+
82
+
83
+ ##
84
+ ## DSL command to check if a param is set
85
+ ##
86
+
87
+ def param_given?(key)
88
+ @task.param_given? key
89
+ end
90
+
91
+
92
+ ##
93
+ ## DSL command to check if a variable is set
94
+ ##
95
+
96
+ def var_given?(key)
97
+ @task.var_given? key
98
+ end
99
+ end
100
+ end
101
+ end