boxing 0.2.0 → 0.4.1

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
2
  SHA256:
3
- metadata.gz: 14f2ef307cfd69550543543bbf5562444e5ab3183e297e71fbb4a067c74c85f6
4
- data.tar.gz: 5d869dd503707d73792e52e153766c96a4030f4894e9a3242a722abdada7dd06
3
+ metadata.gz: fe3d343131564fde7cf4de0e29e3ef500be4107eee0893855473f6efc958eaf5
4
+ data.tar.gz: a2d34fe4ce57859dc44b20ddcd77026f07f24ea25b77d54a15ab6980c1d06817
5
5
  SHA512:
6
- metadata.gz: c6d0e213e1de04a2d4e78884ba8f7cfc500a4c3de81df76343a70eab87372639cbd0c5315252d55eab65a10e7bc9cca7ffc577712be10ab713aab8d87a6416e8
7
- data.tar.gz: b2af368f6b149e19150089363b8512e24c3ad3a82be21b34a256ce89cb176f6ec6bf7bd0599942809c0634bb053e26ca617526e4297a5332e94cdbc629dd1632
6
+ metadata.gz: 37e4a71b5784d2226b0ce46267f299b968a0307930eea655303c1050d7861fcc9ece58e50f8018ac10e243258b22b96e12261a5ff91b99f95c1d9b403643957d
7
+ data.tar.gz: 20ec4384c3be3fbd1f904cd1911aab41c95aa100f1cef6f243a245b1697865131e114ef878a31fca4f88e6f5119edf558986d2c9a669e05a5be1060b65b3f90e
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- boxing (0.2.0)
4
+ boxing (0.4.1)
5
5
  bundler (~> 2.0)
6
6
  thor (~> 1.0)
7
7
 
data/README.md CHANGED
@@ -2,6 +2,8 @@
2
2
 
3
3
  The zero-configuration Dockerfile generator for Ruby.
4
4
 
5
+ > The [Database Repository](https://github.com/elct9620/ruby-boxing-db) will be used for package information.
6
+
5
7
  ## Installation
6
8
 
7
9
  Add this line to your application's Gemfile development group:
@@ -66,9 +68,22 @@ To generate `Dockerfile` for current project
66
68
  bundle exec boxing generate
67
69
  ```
68
70
 
71
+ ### Update
72
+
73
+ To update the database for package information
74
+
75
+ ```ruby
76
+ bundle exec boxing update
77
+ ```
78
+
79
+ > If the generated `Dockerfile` is not satisfy, please try to update it.
80
+
69
81
  ## Roadmap
70
82
 
71
83
  * [x] `Dockerfile` generator
84
+ * [x] `.gitignore` generator
85
+ * [x] Common ignore files
86
+ * [ ] Customizable ignore files
72
87
  * [ ] Customize config file `config/boxing.rb`
73
88
  * [ ] Entrypoint Detection
74
89
  * [x] Openbox (Suggested)
@@ -77,12 +92,14 @@ bundle exec boxing generate
77
92
  * [ ] Ruby
78
93
  * [ ] Package Database
79
94
  * [x] Built-in (Move to standalone repoistory in future)
80
- * [ ] Standalone Repoistory
81
- * [ ] Customize Source
95
+ * [x] Standalone Repoistory
96
+ * [x] Support gems from `git` repoistory
97
+ * [x] Customize Source
82
98
  * [ ] Base Image
83
99
  * [x] Alpine
84
100
  * [ ] Ubuntu
85
- * [ ] Ruby Version
101
+ * [ ] Filter by Ruby Version
102
+ * [ ] Filter by Gem Version
86
103
 
87
104
  ## Development
88
105
 
@@ -13,5 +13,6 @@ module Boxing
13
13
  end
14
14
 
15
15
  require_relative 'commands/generate'
16
+ require_relative 'commands/update'
16
17
  end
17
18
  end
@@ -21,6 +21,8 @@ module Boxing
21
21
  #
22
22
  # @since 0.1.0
23
23
  def execute
24
+ Database.download! unless Database.exist?
25
+
24
26
  template('templates/Dockerfile.tt', 'Dockerfile', context: context.to_binding)
25
27
  template('templates/dockerignore.tt', '.dockerignore', context: context.to_binding)
26
28
  end
@@ -0,0 +1,24 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Boxing
4
+ # :nodoc:
5
+ module Commands
6
+ # The Database Updater
7
+ #
8
+ # @since 0.3.0
9
+ class Update < Thor::Group
10
+ # Update Database
11
+ #
12
+ # @since 0.3.0
13
+ def execute
14
+ if Database.exist?
15
+ Database.new.update!
16
+ else
17
+ Database.download!
18
+ end
19
+ end
20
+ end
21
+
22
+ Boxing::Command.register(Update, 'update', 'update', 'Update Database')
23
+ end
24
+ end
@@ -20,11 +20,14 @@ module Boxing
20
20
  #
21
21
  # @since 0.1.0
22
22
  def packages
23
- @packages ||= Set.new(
24
- @dependencies
25
- .map(&:name)
26
- .flat_map { |name| @database.package_for(name).to_a }
27
- )
23
+ @packages ||=
24
+ Set
25
+ .new(default_packages)
26
+ .merge(
27
+ @dependencies
28
+ .map(&:name)
29
+ .flat_map { |name| @database.package_for(name).to_a }
30
+ )
28
31
  end
29
32
 
30
33
  # Check rubygems exists
@@ -38,6 +41,28 @@ module Boxing
38
41
  @dependencies.any? { |dep| names.include?(dep.name) }
39
42
  end
40
43
 
44
+ # Does any gem from git
45
+ #
46
+ # @return [TrueClass|FalseClass]
47
+ #
48
+ # @since 0.4.0
49
+ def git?
50
+ @dependencies.any?(&:git)
51
+ end
52
+
53
+ # Default packages
54
+ #
55
+ # @return [Array<Boxing::Package>]
56
+ #
57
+ # @since 0.4.0
58
+ def default_packages
59
+ [
60
+ Package.new('build-base', mode: Package::BUILD)
61
+ ]
62
+ .push(git? ? Package.new('git', mode: Package::BUILD) : nil)
63
+ .compact
64
+ end
65
+
41
66
  # Convert to binding
42
67
  #
43
68
  # @return [Binding]
@@ -9,12 +9,80 @@ module Boxing
9
9
  # @since 0.1.0
10
10
  class Database
11
11
  class << self
12
- # The database root
12
+ # Check for the database exists
13
13
  #
14
- # @since 0.1.0
15
- def root
16
- @root ||= Pathname.new(File.dirname(__FILE__)).join('../../database')
14
+ # @param [String] path
15
+ #
16
+ # @return [TrueClass\FalseClass]
17
+ #
18
+ # @since 0.3.0
19
+ def exist?(path = DEFAULT_PATH)
20
+ File.directory?(path) && !(Dir.entries(path) - %w[. ..]).empty?
21
+ end
22
+
23
+ # Download Database
24
+ #
25
+ # @since 0.3.0
26
+ def download!(path = DEFAULT_PATH)
27
+ command = %w[git clone --quiet]
28
+ command << URL << path.to_s
29
+
30
+ raise DownloadFailed, "failed to download #{URL} to #{path}" unless system(*command)
31
+
32
+ new(path)
33
+ end
34
+ end
35
+
36
+ # @since 0.3.0
37
+ class DownloadFailed < RuntimeError; end
38
+
39
+ # @since 0.3.0
40
+ class UpdateFailed < RuntimeError; end
41
+
42
+ # Git URL of the ruby-boxing-db
43
+ #
44
+ # @since 0.3.0
45
+ URL = 'https://github.com/elct9620/ruby-boxing-db.git'
46
+
47
+ # Path to the user's copy of ruby-boxing-db
48
+ #
49
+ # @since 0.3.0
50
+ USER_PATH = Pathname.new(Gem.user_home).join('.local/share/ruby-boxing-db')
51
+
52
+ # @since 0.3.0
53
+ DEFAULT_PATH = ENV['BOXING_DB'] || USER_PATH
54
+
55
+ # @since 0.3.0
56
+ attr_reader :path
57
+
58
+ # Initialize Database
59
+ #
60
+ # @since 0.3.0
61
+ def initialize(path = DEFAULT_PATH)
62
+ @path = path
63
+ end
64
+
65
+ # The Database is Git Repoistory
66
+ #
67
+ # @return [TrueClass|FalseClass]
68
+ #
69
+ # @since 0.3.0
70
+ def git?
71
+ File.directory?(File.join(@path, '.git'))
72
+ end
73
+
74
+ # Update the database
75
+ #
76
+ # @since 0.3.0
77
+ def update!
78
+ return unless git?
79
+
80
+ Dir.chdir(@path) do
81
+ command = %w[git pull --quiet origin main]
82
+ raise UpdateFailed, "failed to update #{@path}" unless system(*command)
17
83
  end
84
+
85
+ true
18
86
  end
19
87
 
20
88
  # Find packages for rubygems
@@ -41,7 +109,7 @@ module Boxing
41
109
  #
42
110
  # @since 0.1.0
43
111
  def each_package_path_for(name, &block)
44
- Dir.glob(Database.root.join('gems', name, '*.yml'), &block)
112
+ Dir.glob(File.join(@path, 'gems', name, '*.yml'), &block)
45
113
  end
46
114
  end
47
115
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Boxing
4
- VERSION = '0.2.0'
4
+ VERSION = '0.4.1'
5
5
  end
@@ -4,7 +4,7 @@ ARG RUBY_VERSION=<%= RUBY_VERSION %>
4
4
  FROM ruby:${RUBY_VERSION}-alpine AS gem
5
5
  ARG APP_ROOT
6
6
 
7
- RUN apk add --no-cache build-base <%= packages.select(&:build?).join(' ') %>
7
+ RUN apk add --no-cache <%= packages.select(&:build?).join(' ') %>
8
8
 
9
9
  RUN mkdir -p ${APP_ROOT}
10
10
  COPY Gemfile Gemfile.lock ${APP_ROOT}/
@@ -29,9 +29,6 @@ ARG APP_ROOT
29
29
  <%- if packages.select(&:runtime?).any? -%>
30
30
  RUN apk add --no-cache <%= packages.select(&:runtime?).join(' ') %>
31
31
 
32
- ARG REVISION
33
- ENV REVISION $REVISION
34
-
35
32
  <%- end -%>
36
33
  COPY --from=gem /usr/local/bundle/config /usr/local/bundle/config
37
34
  COPY --from=gem /usr/local/bundle /usr/local/bundle
@@ -46,6 +43,9 @@ ENV RAILS_LOG_TO_STDOUT=true
46
43
  ENV APP_ROOT=$APP_ROOT
47
44
 
48
45
  COPY . ${APP_ROOT}
46
+
47
+ ARG REVISION
48
+ ENV REVISION $REVISION
49
49
  RUN echo $REVISION > ${SERVER_ROOT}/REVISION
50
50
 
51
51
  # Apply Execute Permission
@@ -8,8 +8,10 @@ docker-compose*.yml
8
8
  # CI/CD
9
9
  .github/
10
10
  .cache/
11
+ .circleci/
11
12
  coverage/
12
13
  spec/
14
+ test/
13
15
  features/
14
16
  .gitlab-ci.yml
15
17
  .travis.yml
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: boxing
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - 蒼時弦也
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-12-21 00:00:00.000000000 Z
11
+ date: 2021-12-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -57,16 +57,11 @@ files:
57
57
  - bin/console
58
58
  - bin/setup
59
59
  - boxing.gemspec
60
- - database/gems/pg/postgresql-dev.yml
61
- - database/gems/pg/postgresql-libs.yml
62
- - database/gems/rails/shared-mime-info.yml
63
- - database/gems/rails/tzdata.yml
64
- - database/gems/sqlite3/sqlite-dev.yml
65
- - database/gems/sqlite3/sqlite-libs.yml
66
60
  - exe/boxing
67
61
  - lib/boxing.rb
68
62
  - lib/boxing/command.rb
69
63
  - lib/boxing/commands/generate.rb
64
+ - lib/boxing/commands/update.rb
70
65
  - lib/boxing/context.rb
71
66
  - lib/boxing/database.rb
72
67
  - lib/boxing/package.rb
@@ -1,2 +0,0 @@
1
- name: postgresql-dev
2
- build: yes
@@ -1,2 +0,0 @@
1
- name: postgresql-libs
2
- runtime: yes
@@ -1,2 +0,0 @@
1
- name: shared-mime-info
2
- runtime: yes
@@ -1,2 +0,0 @@
1
- name: tzdata
2
- runtime: yes
@@ -1,2 +0,0 @@
1
- name: sqlite-dev
2
- build: yes
@@ -1,2 +0,0 @@
1
- name: sqlite-libs
2
- runtime: true