rokkin 0.0.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 +7 -0
- data/bin/rokkin +69 -0
- data/lib/assets/.env +13 -0
- data/lib/assets/Dockerfile +39 -0
- data/lib/assets/Procfile +2 -0
- data/lib/assets/fig.yml +57 -0
- data/lib/rokkin.rb +43 -0
- metadata +78 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 50a90c20c56dcfa2636de4778cc2f6536a82cd7f
|
4
|
+
data.tar.gz: 9e4a1a03651e3e1673855c2b4bce09917bbeebd3
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 485e4cc7eb98285b588aad16cdc5b620c34cbc253154e4ca399066d7bbdd3cda0d1f45a5d9e1bd63f6cb9c4348f05862bf5921b435f5e5ab003c03ea32301a3e
|
7
|
+
data.tar.gz: 31c6e7895588329b324610669f866255cd20929a60816dd823aa5462bfbe0a087b4ae95febb57a04c34a27549b01bfb2b3477619b70bfc4cb6d9d8ac2651e5ea
|
data/bin/rokkin
ADDED
@@ -0,0 +1,69 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'rokkin'
|
4
|
+
require 'thor'
|
5
|
+
require 'git'
|
6
|
+
|
7
|
+
class RokkinCLI < Thor
|
8
|
+
desc "clone URL", "Clones the git repo located at URL into the current directory."
|
9
|
+
option :sha
|
10
|
+
option :path
|
11
|
+
def clone(url)
|
12
|
+
repo_name = url.split('/')[-1].chomp(".git")
|
13
|
+
full_path = File.expand_path(options[:path] || repo_name)
|
14
|
+
|
15
|
+
print "Cloning into #{full_path} ... "
|
16
|
+
begin
|
17
|
+
repo = Git.clone(url, full_path)
|
18
|
+
puts "done"
|
19
|
+
rescue Git::GitExecuteError => e
|
20
|
+
puts "error!"
|
21
|
+
puts e.message
|
22
|
+
exit
|
23
|
+
end
|
24
|
+
|
25
|
+
if options[:sha]
|
26
|
+
print "Checking out #{options[:sha]} ... "
|
27
|
+
begin
|
28
|
+
repo.checkout(options[:sha])
|
29
|
+
puts "done"
|
30
|
+
rescue Git::GitExecuteError => e
|
31
|
+
puts "error!"
|
32
|
+
puts e
|
33
|
+
puts "Checking out HEAD and continuing on ..."
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
containerize(full_path)
|
38
|
+
end
|
39
|
+
|
40
|
+
desc "containerize PATH", "Containerizes the ruby app located at PATH (defaults to the current directory)"
|
41
|
+
option :force, :type => :boolean, :desc => "Overwrites any Dockerfile, Procfile, .env, or fig.yaml file in the destination."
|
42
|
+
def containerize(path='.')
|
43
|
+
full_path = File.expand_path(path)
|
44
|
+
|
45
|
+
print "Containerizing #{full_path} ... "
|
46
|
+
begin
|
47
|
+
Rokkin.containerize(full_path, options)
|
48
|
+
puts "done"
|
49
|
+
puts
|
50
|
+
docs
|
51
|
+
rescue RokkinError => e
|
52
|
+
puts "error!"
|
53
|
+
|
54
|
+
if e.cause # This was caused by someone else (like FileUtils)
|
55
|
+
raise e.cause
|
56
|
+
else # Otherwise it's a RokkinError we raised, so just print that message
|
57
|
+
puts e.message
|
58
|
+
exit
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
desc "docs", "Prints detailed documentation"
|
64
|
+
def docs
|
65
|
+
puts "Detailed documentation is listed at https://github.com/Whitespace/rokkin"
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
RokkinCLI.start(ARGV)
|
data/lib/assets/.env
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
export POSTGRES_HOST=$POSTGRES_PORT_5432_TCP_ADDR
|
2
|
+
export POSTGRES_PORT=$POSTGRES_PORT_5432_TCP_PORT
|
3
|
+
export POSTGRES_USER=postgres
|
4
|
+
|
5
|
+
export REDIS_HOST=$REDIS_PORT_6379_TCP_ADDR
|
6
|
+
export REDIS_PORT=$REDIS_PORT_6379_TCP_PORT
|
7
|
+
export REDIS_DATABASE=1
|
8
|
+
export REDIS_URL="redis://${REDIS_HOST}:${REDIS_PORT}/${REDIS_DATABASE}"
|
9
|
+
|
10
|
+
# export ES_HOST=$ES_PORT_9200_TCP_ADDR
|
11
|
+
# export ES_PORT=$ES_PORT_9200_TCP_PORT
|
12
|
+
# export ES_USER=elasticsearch
|
13
|
+
# export ES_PASS=""
|
@@ -0,0 +1,39 @@
|
|
1
|
+
# Change ruby version here
|
2
|
+
FROM ruby:2.1.5
|
3
|
+
MAINTAINER Tom Clark <whitespace@gmail.com>
|
4
|
+
|
5
|
+
RUN apt-get update -qq && apt-get install -y build-essential
|
6
|
+
|
7
|
+
## DATABASES
|
8
|
+
# sqlite3
|
9
|
+
RUN apt-get install -y sqlite3 libsqlite3-dev
|
10
|
+
# postgres
|
11
|
+
RUN apt-get install -y postgresql
|
12
|
+
# redis
|
13
|
+
RUN apt-get install -y redis-server
|
14
|
+
# elasticsearch
|
15
|
+
RUN apt-get install -y elasticsearch
|
16
|
+
|
17
|
+
## JAVASCRIPT INTERPRETERS
|
18
|
+
# nodejs
|
19
|
+
RUN curl -sL https://deb.nodesource.com/setup | bash -
|
20
|
+
RUN apt-get install -y libsqlite3-dev nodejs
|
21
|
+
|
22
|
+
# Cleanup
|
23
|
+
RUN apt-get autoremove -y
|
24
|
+
|
25
|
+
# Install foreman locally, not via Gemfile as per:
|
26
|
+
# https://github.com/ddollar/foreman#installation
|
27
|
+
RUN gem install foreman
|
28
|
+
|
29
|
+
# throw errors if Gemfile has been modified since Gemfile.lock
|
30
|
+
RUN bundle config --global frozen 1
|
31
|
+
|
32
|
+
RUN mkdir /usr/src/app
|
33
|
+
WORKDIR /usr/src/app
|
34
|
+
|
35
|
+
ADD Gemfile /usr/src/app/Gemfile
|
36
|
+
ADD Gemfile.lock /usr/src/app/Gemfile.lock
|
37
|
+
RUN bundle install
|
38
|
+
|
39
|
+
ADD . /usr/src/app
|
data/lib/assets/Procfile
ADDED
data/lib/assets/fig.yml
ADDED
@@ -0,0 +1,57 @@
|
|
1
|
+
# Quick Summary
|
2
|
+
# =============
|
3
|
+
# * command is the command run when the container is run. It overrides CMD in
|
4
|
+
# your Dockerfile.
|
5
|
+
# * build . means the Dockerfile is in the current directory
|
6
|
+
# * ports are the ports the container exposes to the host OS. If you get a
|
7
|
+
# conflict, you're probably running that same service locally. Either
|
8
|
+
# change the mapping or disable it entirely (also disable the ports: key!)
|
9
|
+
# * volumes are used to share a path from the host to the container. Use this
|
10
|
+
# if you want to persist data outside the container, or modify data inside
|
11
|
+
# the container easily
|
12
|
+
# * Comment out or remove anything you don't need
|
13
|
+
# * Also, feel free to change the names from web/worker to api/whatever
|
14
|
+
# * Note that you can't use YAML default: &default to share settings, as fig
|
15
|
+
# does not properly handle that right now
|
16
|
+
|
17
|
+
web:
|
18
|
+
command: foreman start web
|
19
|
+
build: .
|
20
|
+
ports:
|
21
|
+
- "8080:8080"
|
22
|
+
volumes:
|
23
|
+
- .:/usr/src/app
|
24
|
+
links:
|
25
|
+
- postgres
|
26
|
+
- redis
|
27
|
+
- elasticsearch
|
28
|
+
postgres:
|
29
|
+
# https://registry.hub.docker.com/_/postgres/
|
30
|
+
image: "postgres:9.3.5"
|
31
|
+
expose:
|
32
|
+
- 5432
|
33
|
+
ports:
|
34
|
+
- "5432:5432"
|
35
|
+
# volumes:
|
36
|
+
# # homebrew datadirectory:image data directory
|
37
|
+
# - /usr/local/var/postgres:/var/lib/postgresql/data
|
38
|
+
redis:
|
39
|
+
# https://registry.hub.docker.com/u/dockerfile/redis/
|
40
|
+
image: "dockerfile/redis"
|
41
|
+
expose:
|
42
|
+
- 6379
|
43
|
+
ports:
|
44
|
+
- "6379:6379"
|
45
|
+
# volumes:
|
46
|
+
# # homebrew datadirectory:image data directory
|
47
|
+
# - /usr/local/var/db/redis:/data
|
48
|
+
elasticsearch:
|
49
|
+
# https://registry.hub.docker.com/u/dockerfile/elasticsearch/
|
50
|
+
image: "dockerfile/elasticsearch"
|
51
|
+
expose:
|
52
|
+
- 9200
|
53
|
+
ports:
|
54
|
+
- "9200:9200"
|
55
|
+
# volumes:
|
56
|
+
# # homebrew datadirectory:image data directory
|
57
|
+
# - /usr/local/var/db/redis:/data
|
data/lib/rokkin.rb
ADDED
@@ -0,0 +1,43 @@
|
|
1
|
+
require 'fileutils'
|
2
|
+
|
3
|
+
class RokkinError < StandardError; end
|
4
|
+
|
5
|
+
class Rokkin
|
6
|
+
# Copies assets from lib/assets to path
|
7
|
+
def self.containerize(path, options={:force => false})
|
8
|
+
bin_path = File.expand_path(File.dirname(__FILE__))
|
9
|
+
asset_path = File.join(bin_path, "..", "lib", "assets")
|
10
|
+
assets = Dir.entries(asset_path) - ['.', '..']
|
11
|
+
|
12
|
+
asset_list = assets.map do |filename|
|
13
|
+
File.join(asset_path, filename)
|
14
|
+
end
|
15
|
+
|
16
|
+
# Are we going to overwrite an existing file?
|
17
|
+
existing_files = assets - (assets - Dir.entries(path))
|
18
|
+
|
19
|
+
if options[:force] || existing_files.empty?
|
20
|
+
begin
|
21
|
+
FileUtils.cp(asset_list, path, :preserve => true)
|
22
|
+
rescue Errno::EACCES => e
|
23
|
+
raise RokkinError.new(e.message)
|
24
|
+
end
|
25
|
+
else
|
26
|
+
message = RokkinHelper.strip_heredoc <<-MSG
|
27
|
+
Cannot overwrite the following files: #{existing_files}
|
28
|
+
Remove files or retry with --force
|
29
|
+
MSG
|
30
|
+
raise RokkinError.new(message)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
class RokkinHelper
|
36
|
+
# Modified from http://api.rubyonrails.org/classes/String.html#method-i-strip_heredoc
|
37
|
+
# which linked to https://github.com/rails/rails/blob/b422cda2ebfff4032f4c18271e96ad329c413dcc/activesupport/lib/active_support/core_ext/string/strip.rb#L22
|
38
|
+
# File activesupport/lib/active_support/core_ext/string/strip.rb, line 22
|
39
|
+
def self.strip_heredoc(heredoc)
|
40
|
+
indent = heredoc.scan(/^[ \t]*(?=\S)/).min.length || 0
|
41
|
+
heredoc.gsub(/^[ \t]{#{indent}}/, '')
|
42
|
+
end
|
43
|
+
end
|
metadata
ADDED
@@ -0,0 +1,78 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: rokkin
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.4
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Tom Clark
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-12-21 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: git
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.2'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.2'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: thor
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0.19'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0.19'
|
41
|
+
description: A fast way to containerize your ruby webapps
|
42
|
+
email: whitespace@gmail.com
|
43
|
+
executables:
|
44
|
+
- rokkin
|
45
|
+
extensions: []
|
46
|
+
extra_rdoc_files: []
|
47
|
+
files:
|
48
|
+
- bin/rokkin
|
49
|
+
- lib/assets/.env
|
50
|
+
- lib/assets/Dockerfile
|
51
|
+
- lib/assets/Procfile
|
52
|
+
- lib/assets/fig.yml
|
53
|
+
- lib/rokkin.rb
|
54
|
+
homepage: http://rubygems.org/gems/rokkin
|
55
|
+
licenses:
|
56
|
+
- MIT
|
57
|
+
metadata: {}
|
58
|
+
post_install_message:
|
59
|
+
rdoc_options: []
|
60
|
+
require_paths:
|
61
|
+
- lib
|
62
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
63
|
+
requirements:
|
64
|
+
- - ">="
|
65
|
+
- !ruby/object:Gem::Version
|
66
|
+
version: '0'
|
67
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
68
|
+
requirements:
|
69
|
+
- - ">="
|
70
|
+
- !ruby/object:Gem::Version
|
71
|
+
version: '0'
|
72
|
+
requirements: []
|
73
|
+
rubyforge_project:
|
74
|
+
rubygems_version: 2.2.2
|
75
|
+
signing_key:
|
76
|
+
specification_version: 4
|
77
|
+
summary: Rokkin!
|
78
|
+
test_files: []
|