trokko 0.2.0

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 66ea7fb21c0fcfa9f41f7bff08b4d3cbc55353a281ad0fe229dbfa25e1680673
4
+ data.tar.gz: c4f79262437fb593cee9ce35f168791de1c59ccd7da9ecce76224741ae235ddd
5
+ SHA512:
6
+ metadata.gz: 6da449d463753931d070908a0a52033842fcb2cb1325d5d6640ea11fcb7b7dbbb0e4b72473b94793d983b63119ae923580c02a5d6ab15871d39907cca8ed87b6
7
+ data.tar.gz: 2f620fd05c86246c7e895e03f9059cf590662cd04ffd34d9f6299af96c5aada134b15493402024725fac67cd46fde2e141dd6fd7b43a106eb9b27ddc9aafe3a4
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
data/.rubocop.yml ADDED
@@ -0,0 +1,20 @@
1
+ require:
2
+ - rubocop-rspec
3
+ - rubocop-rake
4
+
5
+ inherit_from: .rubocop_todo.yml
6
+
7
+ AllCops:
8
+ TargetRubyVersion: 2.7
9
+ NewCops: enable
10
+ Exclude:
11
+ - exe/**/*
12
+ - vendor/**/*
13
+ - sandbox/**/*
14
+
15
+ Layout/LineLength:
16
+ Max: 120
17
+
18
+ Metrics/BlockLength:
19
+ Exclude:
20
+ - spec/**/*_spec.rb
data/.rubocop_todo.yml ADDED
@@ -0,0 +1,17 @@
1
+ # This configuration was generated by
2
+ # `rubocop --auto-gen-config`
3
+ # on 2022-06-25 14:58:22 UTC using RuboCop version 1.30.1.
4
+ # The point is for the user to remove these configuration records
5
+ # one by one as the offenses are removed from the code base.
6
+ # Note that changes in the inspected code, or installation of new
7
+ # versions of RuboCop, may require this file to be generated again.
8
+
9
+ # Offense count: 1
10
+ # Configuration parameters: CountComments, CountAsOne.
11
+ Metrics/ClassLength:
12
+ Max: 111
13
+
14
+ # Offense count: 1
15
+ # Configuration parameters: CountComments, CountAsOne, ExcludedMethods, IgnoredMethods.
16
+ Metrics/MethodLength:
17
+ Max: 18
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ 2.7.6
data/CHANGELOG.md ADDED
@@ -0,0 +1,43 @@
1
+ # Changelog
2
+
3
+ ## [v0.2.0](https://github.com/snaka/trokko/tree/v0.2.0) (2022-07-01)
4
+
5
+ [Full Changelog](https://github.com/snaka/trokko/compare/v0.1.0...v0.2.0)
6
+
7
+ **Closed issues:**
8
+
9
+ - A gem with the same name already exists [\#16](https://github.com/snaka/trokko/issues/16)
10
+
11
+ **Merged pull requests:**
12
+
13
+ - Bump version to 0.2.0 [\#21](https://github.com/snaka/trokko/pull/21) ([snaka](https://github.com/snaka))
14
+ - Support ruby 2.7 [\#20](https://github.com/snaka/trokko/pull/20) ([snaka](https://github.com/snaka))
15
+ - Rename to `trokko` [\#19](https://github.com/snaka/trokko/pull/19) ([snaka](https://github.com/snaka))
16
+ - Test cli [\#18](https://github.com/snaka/trokko/pull/18) ([snaka](https://github.com/snaka))
17
+ - refine gemspec text [\#17](https://github.com/snaka/trokko/pull/17) ([snaka](https://github.com/snaka))
18
+
19
+ ## [v0.1.0](https://github.com/snaka/trokko/tree/v0.1.0) (2022-06-29)
20
+
21
+ [Full Changelog](https://github.com/snaka/trokko/compare/bf6b53382c31098eddcd4f1e393810b2c5dea43b...v0.1.0)
22
+
23
+ **Merged pull requests:**
24
+
25
+ - Centerize cover image [\#15](https://github.com/snaka/trokko/pull/15) ([snaka](https://github.com/snaka))
26
+ - Add version option [\#14](https://github.com/snaka/trokko/pull/14) ([snaka](https://github.com/snaka))
27
+ - fix undefined identifier [\#13](https://github.com/snaka/trokko/pull/13) ([snaka](https://github.com/snaka))
28
+ - A unique label is added to the Docker volume to be created. [\#12](https://github.com/snaka/trokko/pull/12) ([snaka](https://github.com/snaka))
29
+ - Fix docker compose template [\#11](https://github.com/snaka/trokko/pull/11) ([snaka](https://github.com/snaka))
30
+ - Fix Gemfile.lock location [\#10](https://github.com/snaka/trokko/pull/10) ([snaka](https://github.com/snaka))
31
+ - refine README [\#9](https://github.com/snaka/trokko/pull/9) ([snaka](https://github.com/snaka))
32
+ - Templatization [\#8](https://github.com/snaka/trokko/pull/8) ([snaka](https://github.com/snaka))
33
+ - Add --skip-build option [\#7](https://github.com/snaka/trokko/pull/7) ([snaka](https://github.com/snaka))
34
+ - Remove unnecessary require 'debug' [\#6](https://github.com/snaka/trokko/pull/6) ([snaka](https://github.com/snaka))
35
+ - Remove unnecessary nodejs installation from the Dockerfile [\#5](https://github.com/snaka/trokko/pull/5) ([snaka](https://github.com/snaka))
36
+ - Maintain readme [\#4](https://github.com/snaka/trokko/pull/4) ([snaka](https://github.com/snaka))
37
+ - fix typo [\#3](https://github.com/snaka/trokko/pull/3) ([snaka](https://github.com/snaka))
38
+ - Implement CLI [\#2](https://github.com/snaka/trokko/pull/2) ([snaka](https://github.com/snaka))
39
+ - Implement scaffolders [\#1](https://github.com/snaka/trokko/pull/1) ([snaka](https://github.com/snaka))
40
+
41
+
42
+
43
+ \* *This Changelog was automatically generated by [github_changelog_generator](https://github.com/github-changelog-generator/github-changelog-generator)*
data/Gemfile ADDED
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ source 'https://rubygems.org'
4
+
5
+ # Specify your gem's dependencies in trokko.gemspec
6
+ gemspec
7
+
8
+ gem 'rake', '~> 13.0'
9
+
10
+ gem 'rspec', '~> 3.0'
11
+ gem 'rspec-temp_dir', '~> 1.1'
12
+
13
+ gem 'rubocop', '~> 1.21'
14
+ gem 'rubocop-rake', '~> 0.6'
15
+ gem 'rubocop-rspec', '~> 2.11'
16
+
17
+ gem 'debug', '~> 1.0'
data/Gemfile.lock ADDED
@@ -0,0 +1,76 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ trokko (0.2.0)
5
+ thor (~> 1.2.0)
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ ast (2.4.2)
11
+ debug (1.0.0)
12
+ irb
13
+ reline (>= 0.2.7)
14
+ diff-lcs (1.5.0)
15
+ io-console (0.5.11)
16
+ irb (1.4.1)
17
+ reline (>= 0.3.0)
18
+ parallel (1.22.1)
19
+ parser (3.1.2.0)
20
+ ast (~> 2.4.1)
21
+ rainbow (3.1.1)
22
+ rake (13.0.6)
23
+ regexp_parser (2.5.0)
24
+ reline (0.3.1)
25
+ io-console (~> 0.5)
26
+ rexml (3.2.5)
27
+ rspec (3.11.0)
28
+ rspec-core (~> 3.11.0)
29
+ rspec-expectations (~> 3.11.0)
30
+ rspec-mocks (~> 3.11.0)
31
+ rspec-core (3.11.0)
32
+ rspec-support (~> 3.11.0)
33
+ rspec-expectations (3.11.0)
34
+ diff-lcs (>= 1.2.0, < 2.0)
35
+ rspec-support (~> 3.11.0)
36
+ rspec-mocks (3.11.1)
37
+ diff-lcs (>= 1.2.0, < 2.0)
38
+ rspec-support (~> 3.11.0)
39
+ rspec-support (3.11.0)
40
+ rspec-temp_dir (1.1.1)
41
+ rspec (>= 3.0)
42
+ rubocop (1.30.1)
43
+ parallel (~> 1.10)
44
+ parser (>= 3.1.0.0)
45
+ rainbow (>= 2.2.2, < 4.0)
46
+ regexp_parser (>= 1.8, < 3.0)
47
+ rexml (>= 3.2.5, < 4.0)
48
+ rubocop-ast (>= 1.18.0, < 2.0)
49
+ ruby-progressbar (~> 1.7)
50
+ unicode-display_width (>= 1.4.0, < 3.0)
51
+ rubocop-ast (1.18.0)
52
+ parser (>= 3.1.1.0)
53
+ rubocop-rake (0.6.0)
54
+ rubocop (~> 1.0)
55
+ rubocop-rspec (2.11.1)
56
+ rubocop (~> 1.19)
57
+ ruby-progressbar (1.11.0)
58
+ thor (1.2.1)
59
+ unicode-display_width (2.1.0)
60
+
61
+ PLATFORMS
62
+ ruby
63
+ x86_64-linux
64
+
65
+ DEPENDENCIES
66
+ debug (~> 1.0)
67
+ rake (~> 13.0)
68
+ rspec (~> 3.0)
69
+ rspec-temp_dir (~> 1.1)
70
+ rubocop (~> 1.21)
71
+ rubocop-rake (~> 0.6)
72
+ rubocop-rspec (~> 2.11)
73
+ trokko!
74
+
75
+ BUNDLED WITH
76
+ 2.3.14
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2022 Shinji Nakamatsu
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 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,
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 THE
21
+ SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,50 @@
1
+ <p align="center">
2
+ <img src="docs/images/cover-image.png?raw=true" width="600px">
3
+ </p>
4
+
5
+ # Trokko
6
+
7
+ Do you think the steps involved in building a Rails application development environment with Docker are too complicated?
8
+
9
+ The `trokko` command solves this for you.
10
+
11
+ The `trokko` command prepares the specified `Gemfile` template.
12
+ It will prepare a `Dockerfile` or `docker-compose.yml` depending on the specified DBMS.
13
+ Then, it runs `rails new` and gets you ready to start development right away.
14
+ It takes about a minute.
15
+
16
+ ## Installation
17
+
18
+ The installation process is as follows
19
+
20
+ $ gem install trokko
21
+
22
+ ## Usage
23
+
24
+ ```
25
+ Usage:
26
+ trokko generate [NAME]
27
+
28
+ Options:
29
+ [--ruby-version=RUBY_VERSION] # Ruby version (docker image tag)
30
+ # Default: latest
31
+ [--db=DB]
32
+ # Default: mysql
33
+ # Possible values: mysql, postgresql
34
+ [--skip-build], [--no-skip-build] # Skip build
35
+ [--force] # Force to execute
36
+ ```
37
+
38
+ ## Development
39
+
40
+ 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.
41
+
42
+ 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 the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
43
+
44
+ ## Contributing
45
+
46
+ Bug reports and pull requests are welcome on GitHub at https://github.com/snaka/trokko.
47
+
48
+ ## License
49
+
50
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'bundler/gem_tasks'
4
+ require 'rspec/core/rake_task'
5
+
6
+ RSpec::Core::RakeTask.new(:spec)
7
+
8
+ require 'rubocop/rake_task'
9
+
10
+ RuboCop::RakeTask.new
11
+
12
+ task default: %i[spec rubocop]
13
+
14
+ desc 'Execute sandbox test'
15
+ task :sandbox do
16
+ system 'bundle exec exe/trokko generate sandbox --force'
17
+ end
Binary file
data/exe/trokko ADDED
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env ruby
2
+ require 'trokko/cli'
3
+
4
+ Trokko::CLI.start(ARGV)
data/lib/trokko/cli.rb ADDED
@@ -0,0 +1,162 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'fileutils'
4
+ require 'thor'
5
+ require 'trokko'
6
+
7
+ module Trokko
8
+ # Generate rails application
9
+ class Generate < Thor::Group
10
+ include Thor::Actions
11
+
12
+ desc 'Generate rails application on docker'
13
+
14
+ argument :name, type: :string, required: false
15
+
16
+ class_option :ruby_version, default: 'latest', desc: 'Ruby version (docker image tag)'
17
+ class_option :db, default: 'mysql', enum: %w[mysql postgresql], desc: 'DBMS to use'
18
+ class_option :skip_build, type: :boolean, default: false, desc: 'Skip build'
19
+ class_option :force, type: :boolean, default: false, desc: 'Force to execute'
20
+
21
+ def self.source_root
22
+ File.dirname(__FILE__)
23
+ end
24
+
25
+ def ask_project_name
26
+ @name = ask('Project name:') unless name
27
+ return unless @name.empty?
28
+
29
+ CLI.command_help(shell, 'generate')
30
+ say 'Stop executing task', :red
31
+ raise Thor::InvocationError, '[ERROR] Project name is required'
32
+ end
33
+
34
+ def confirm
35
+ say "- Project name: #{name}", :cyan
36
+ say "- Ruby version: #{ruby_version}", :cyan
37
+ say "- Database: #{db}", :cyan
38
+
39
+ return if ask('Are you sure to execute the settings described above?', limited_to: %w[y n]) == 'y'
40
+
41
+ say 'Stop executing task', :red
42
+ raise Thor::InvocationError, 'You choose *NOT* to execute.'
43
+ end
44
+
45
+ def check_directory
46
+ say 'check directory...', :yellow
47
+ say File.exist?(name)
48
+ return unless File.exist?(name)
49
+ FileUtils.remove_dir(name) and return if force
50
+
51
+ say 'Stop executing task', :red
52
+ raise Thor::InvocationError,
53
+ "[ERROR] Directory '#{name}' already exists. " \
54
+ "If you are sure executing is OK, specify the '--force' option. The directory will be removed."
55
+ end
56
+
57
+ def dockerfile
58
+ say 'Generating Dockerfile...', :yellow
59
+ Scaffolders::Dockerfile.new(ruby_version: ruby_version, db: db, thor: self).generate
60
+ Scaffolders::Entrypoint.new(thor: self).generate
61
+ end
62
+
63
+ def gemfile
64
+ say 'Generating Gemfile...', :yellow
65
+ Scaffolders::Gemfile.new(rails_version: '7.0.0', thor: self).generate
66
+ inside name do
67
+ FileUtils.touch 'Gemfile.lock'
68
+ end
69
+ end
70
+
71
+ def docker_compose
72
+ say 'Generating docker-compose.yml...', :yellow
73
+ Scaffolders::DockerCompose.new(db: db, thor: self).generate
74
+ end
75
+
76
+ def rails_new
77
+ say 'Generating rails application...', :yellow
78
+ inside name do
79
+ unless system(
80
+ "docker compose run --no-deps --entrypoint '' --rm app" \
81
+ " bundle exec rails new . --database=#{db} --force"
82
+ )
83
+ say 'Stop executing task', :red
84
+ raise Thor::InvocationError, '[ERROR] Failed to generate rails application'
85
+ end
86
+
87
+ return if File.stat('config').uid == uid
88
+
89
+ unless system(
90
+ "docker compose run --no-deps --entrypoint '' --rm app" \
91
+ " chown -R #{uid}:#{gid} ."
92
+ )
93
+ say 'Stop executing task', :red
94
+ raise Thor::InvocationError, '[ERROR] Failed to change owner of generated files'
95
+ end
96
+ end
97
+ end
98
+
99
+ def post_rails_new
100
+ say 'Generating database.yml...', :yellow
101
+ Scaffolders::Config::Database.new(db: db, thor: self).generate
102
+ end
103
+
104
+ def docker
105
+ return if skip_build
106
+
107
+ say 'Building docker image...', :yellow
108
+ inside name do
109
+ return if system('docker compose build')
110
+
111
+ say 'Stop executing task', :red
112
+ raise Thor::InvocationError, '[ERROR] Failed to build docker image'
113
+ end
114
+ end
115
+
116
+ def finished
117
+ say 'Finished!', :green
118
+ end
119
+
120
+ private
121
+
122
+ def force
123
+ options[:force]
124
+ end
125
+
126
+ def ruby_version
127
+ options[:ruby_version]
128
+ end
129
+
130
+ def db
131
+ options[:db]
132
+ end
133
+
134
+ def skip_build
135
+ options[:skip_build]
136
+ end
137
+
138
+ def uid
139
+ Process.uid
140
+ end
141
+
142
+ def gid
143
+ Process.gid
144
+ end
145
+ end
146
+
147
+ # CLI for Trokko
148
+ class CLI < Thor
149
+ def self.exit_on_failure?
150
+ true
151
+ end
152
+
153
+ register(Generate, 'generate', 'generate [NAME]', 'Generate a Rails application with the specified name')
154
+ tasks['generate'].options = Generate.class_options
155
+
156
+ desc 'version', 'Show version'
157
+ def version
158
+ say "trokko #{Trokko::VERSION}"
159
+ end
160
+ map %w[-v --version] => :version
161
+ end
162
+ end
@@ -0,0 +1,37 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Trokko
4
+ module Scaffolders
5
+ module Config
6
+ # Generating config/database.yml file according to configurations
7
+ class Database
8
+ attr_reader :db, :thor
9
+
10
+ def initialize(db:, thor:)
11
+ @db = db
12
+ @thor = thor
13
+ end
14
+
15
+ def generate
16
+ thor.template(
17
+ 'templates/config/database.yml.erb',
18
+ "#{thor.name}/config/database.yml",
19
+ force: true,
20
+ context: binding
21
+ )
22
+ end
23
+
24
+ private
25
+
26
+ def db_config
27
+ erb_source = File.read("#{source_root}/templates/config/database/#{db}.yml.erb")
28
+ ERB.new(erb_source).result(binding)
29
+ end
30
+
31
+ def source_root
32
+ thor.class.source_root
33
+ end
34
+ end
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,44 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Trokko
4
+ module Scaffolders
5
+ # Generating docker-compose file according to configuration
6
+ class DockerCompose
7
+ attr_reader :db, :thor
8
+
9
+ def initialize(db:, thor:)
10
+ @db = db
11
+ @thor = thor
12
+ end
13
+
14
+ def generate
15
+ thor.template(
16
+ 'templates/docker-compose.yml.erb',
17
+ "#{thor.name}/docker-compose.yml",
18
+ force: true,
19
+ context: binding
20
+ )
21
+ end
22
+
23
+ private
24
+
25
+ def db_service_config
26
+ erb_source = File.read("#{source_root}/templates/docker_compose/#{db}/db_service.erb")
27
+ ERB.new(erb_source).result(binding)
28
+ end
29
+
30
+ def app_service_config
31
+ erb_source = File.read("#{source_root}/templates/docker_compose/#{db}/app_service.erb")
32
+ ERB.new(erb_source).result(binding)
33
+ end
34
+
35
+ def source_root
36
+ thor.class.source_root
37
+ end
38
+
39
+ def project_name
40
+ thor.name
41
+ end
42
+ end
43
+ end
44
+ end
@@ -0,0 +1,38 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Trokko
4
+ module Scaffolders
5
+ # Generating Dockerfile according to configurations
6
+ class Dockerfile
7
+ attr_reader :ruby_version, :db, :thor
8
+
9
+ def initialize(ruby_version:, db:, thor:)
10
+ @ruby_version = ruby_version
11
+ @db = db
12
+ @thor = thor
13
+ end
14
+
15
+ def generate
16
+ thor.template(
17
+ 'templates/Dockerfile.erb',
18
+ "#{thor.name}/Dockerfile",
19
+ force: true,
20
+ context: binding
21
+ )
22
+ end
23
+
24
+ private
25
+
26
+ def db_dependencies
27
+ case db
28
+ when 'mysql'
29
+ ''
30
+ when 'postgresql'
31
+ 'libpq-dev'
32
+ else
33
+ raise "Unknown database: #{db}"
34
+ end
35
+ end
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,23 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Trokko
4
+ module Scaffolders
5
+ # Generating entrypoint.sh file according to configurations
6
+ class Entrypoint
7
+ attr_reader :thor
8
+
9
+ def initialize(thor:)
10
+ @thor = thor
11
+ end
12
+
13
+ def generate
14
+ thor.template(
15
+ 'templates/entrypoint.sh.erb',
16
+ "#{thor.name}/entrypoint.sh",
17
+ force: true,
18
+ context: binding
19
+ )
20
+ end
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,24 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Trokko
4
+ module Scaffolders
5
+ # Generationg Gemfile according to configurations
6
+ class Gemfile
7
+ attr_reader :rails_version, :thor
8
+
9
+ def initialize(rails_version:, thor:)
10
+ @rails_version = rails_version
11
+ @thor = thor
12
+ end
13
+
14
+ def generate
15
+ thor.template(
16
+ 'templates/Gemfile.erb',
17
+ "#{thor.name}/Gemfile",
18
+ force: true,
19
+ context: binding
20
+ )
21
+ end
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,17 @@
1
+ FROM ruby:<%= ruby_version %>
2
+
3
+ RUN apt-get update -qq && apt-get install -y build-essential <%= db_dependencies %>
4
+
5
+ RUN mkdir /app
6
+ WORKDIR /app
7
+ COPY Gemfile /app/Gemfile
8
+ COPY Gemfile.lock /app/Gemfile.lock
9
+ RUN gem update bundler && bundle install
10
+ COPY . /app
11
+
12
+ COPY entrypoint.sh /usr/bin/
13
+ RUN chmod +x /usr/bin/entrypoint.sh
14
+ ENTRYPOINT ["entrypoint.sh"]
15
+ EXPOSE 3000
16
+
17
+ CMD ["bundle", "exec", "rails", "server", "--binding", "0.0.0.0"]
@@ -0,0 +1,2 @@
1
+ source 'https://rubygems.org'
2
+ gem 'rails', '~><%= rails_version %>'
@@ -0,0 +1,4 @@
1
+ adapter: mysql2
2
+ encoding: utf8
3
+ username: root
4
+ password: <%%= ENV.fetch("MYSQL_ROOT_PASSWORD") %>
@@ -0,0 +1,3 @@
1
+ adapter: postgresql
2
+ encoding: unicode
3
+ user: postgres
@@ -0,0 +1,18 @@
1
+ default: &default
2
+ <%= db_config %>
3
+ host: db
4
+ pool: <%%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
5
+
6
+ development:
7
+ <<: *default
8
+ database: app_development
9
+
10
+ test:
11
+ <<: *default
12
+ database: app_test
13
+
14
+ production:
15
+ <<: *default
16
+ database: app_production
17
+ username: app
18
+ password: <%%= ENV["APP_DATABASE_PASSWORD"] %>
@@ -0,0 +1,23 @@
1
+ version: '3'
2
+ services:
3
+ db:
4
+ <%= db_service_config %>
5
+ app:
6
+ build: .
7
+ volumes:
8
+ - .:/app
9
+ - bundle:/usr/local/bundle
10
+ ports:
11
+ - "3000:3000"
12
+ depends_on:
13
+ - db
14
+ <%= app_service_config %>
15
+ volumes:
16
+ database:
17
+ driver: local
18
+ labels:
19
+ info.snaka.trokko.project: "<%= project_name %>"
20
+ bundle:
21
+ driver: local
22
+ labels:
23
+ info.snaka.trokko.project: "<%= project_name %>"
@@ -0,0 +1,2 @@
1
+ environment:
2
+ MYSQL_ROOT_PASSWORD: *db_password
@@ -0,0 +1,8 @@
1
+ image: mysql:latest
2
+ cap_add:
3
+ - SYS_NICE
4
+ environment:
5
+ MYSQL_ROOT_PASSWORD: &db_password secret
6
+ TZ: Asia/Tokyo
7
+ volumes:
8
+ - database:/var/lib/mysql
@@ -0,0 +1,5 @@
1
+ image: postgres:latest
2
+ environment:
3
+ POSTGRES_HOST_AUTH_METHOD: trust
4
+ volumes:
5
+ - database:/var/lib/postgresql/data
@@ -0,0 +1,12 @@
1
+ #!/usr/bin/env bash
2
+ set -e
3
+ set -u
4
+ set -o pipefail
5
+
6
+ bundle install
7
+
8
+ # Remove a potentially pre-existing server.pid for Rails.
9
+ rm -f /app/tmp/pids/server.pid
10
+
11
+ # Then exec the container's main process (what's set as CMD in the Dockerfile).
12
+ exec "$@"
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Trokko
4
+ VERSION = '0.2.0'
5
+ end
data/lib/trokko.rb ADDED
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'trokko/version'
4
+ require_relative 'trokko/scaffolders/dockerfile'
5
+ require_relative 'trokko/scaffolders/docker_compose'
6
+ require_relative 'trokko/scaffolders/gemfile'
7
+ require_relative 'trokko/scaffolders/entrypoint'
8
+ require_relative 'trokko/scaffolders/config/database'
9
+
10
+ module Trokko
11
+ class Error < StandardError; end
12
+ # Your code goes here...
13
+ end
data/sig/trokko.rbs ADDED
@@ -0,0 +1,4 @@
1
+ module Trokko
2
+ VERSION: String
3
+ # See the writing guide of rbs: https://github.com/ruby/rbs#guides
4
+ end
metadata ADDED
@@ -0,0 +1,96 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: trokko
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.2.0
5
+ platform: ruby
6
+ authors:
7
+ - S.Nakamatsu
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2022-07-01 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: thor
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 1.2.0
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.0
27
+ description: |
28
+ The `trokko` command prepares the specified `Gemfile` template.
29
+ It will prepare a `Dockerfile` or `docker-compose.yml` depending on the specified DBMS.
30
+ Then, it runs `rails new` and gets you ready to start development right away.
31
+ It takes about a minute.
32
+ email:
33
+ - 19329+snaka@users.noreply.github.com
34
+ executables:
35
+ - trokko
36
+ extensions: []
37
+ extra_rdoc_files: []
38
+ files:
39
+ - ".rspec"
40
+ - ".rubocop.yml"
41
+ - ".rubocop_todo.yml"
42
+ - ".ruby-version"
43
+ - CHANGELOG.md
44
+ - Gemfile
45
+ - Gemfile.lock
46
+ - LICENSE
47
+ - README.md
48
+ - Rakefile
49
+ - docs/images/cover-image.png
50
+ - exe/trokko
51
+ - lib/trokko.rb
52
+ - lib/trokko/cli.rb
53
+ - lib/trokko/scaffolders/config/database.rb
54
+ - lib/trokko/scaffolders/docker_compose.rb
55
+ - lib/trokko/scaffolders/dockerfile.rb
56
+ - lib/trokko/scaffolders/entrypoint.rb
57
+ - lib/trokko/scaffolders/gemfile.rb
58
+ - lib/trokko/templates/Dockerfile.erb
59
+ - lib/trokko/templates/Gemfile.erb
60
+ - lib/trokko/templates/config/database.yml.erb
61
+ - lib/trokko/templates/config/database/mysql.yml.erb
62
+ - lib/trokko/templates/config/database/postgresql.yml.erb
63
+ - lib/trokko/templates/docker-compose.yml.erb
64
+ - lib/trokko/templates/docker_compose/mysql/app_service.erb
65
+ - lib/trokko/templates/docker_compose/mysql/db_service.erb
66
+ - lib/trokko/templates/docker_compose/postgresql/app_service.erb
67
+ - lib/trokko/templates/docker_compose/postgresql/db_service.erb
68
+ - lib/trokko/templates/entrypoint.sh.erb
69
+ - lib/trokko/version.rb
70
+ - sig/trokko.rbs
71
+ homepage: https://github.com/snaka/trokko
72
+ licenses:
73
+ - MIT
74
+ metadata:
75
+ homepage_uri: https://github.com/snaka/trokko
76
+ rubygems_mfa_required: 'true'
77
+ post_install_message:
78
+ rdoc_options: []
79
+ require_paths:
80
+ - lib
81
+ required_ruby_version: !ruby/object:Gem::Requirement
82
+ requirements:
83
+ - - ">="
84
+ - !ruby/object:Gem::Version
85
+ version: 2.7.0
86
+ required_rubygems_version: !ruby/object:Gem::Requirement
87
+ requirements:
88
+ - - ">="
89
+ - !ruby/object:Gem::Version
90
+ version: '0'
91
+ requirements: []
92
+ rubygems_version: 3.3.14
93
+ signing_key:
94
+ specification_version: 4
95
+ summary: Set up a Rails development environment with Docker in 1 minute
96
+ test_files: []