boxing 0.1.0 → 0.3.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 +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +59 -3
- data/lib/boxing/command.rb +1 -0
- data/lib/boxing/commands/generate.rb +3 -0
- data/lib/boxing/commands/update.rb +24 -0
- data/lib/boxing/database.rb +73 -5
- data/lib/boxing/version.rb +1 -1
- data/templates/Dockerfile.tt +4 -0
- data/templates/dockerignore.tt +33 -0
- metadata +4 -8
- data/database/gems/pg/postgresql-dev.yml +0 -2
- data/database/gems/pg/postgresql-libs.yml +0 -2
- data/database/gems/rails/shared-mime-info.yml +0 -2
- data/database/gems/rails/tzdata.yml +0 -2
- data/database/gems/sqlite3/sqlite-dev.yml +0 -2
- data/database/gems/sqlite3/sqlite-libs.yml +0 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bc45fc502d0e92045969b463a8371bfd70c0375903be656554d0b0523a4e54db
|
4
|
+
data.tar.gz: 2f65fa15db1b98e7f2c8b58c592fdef26feb484408d1bdc75329f882b0561f6c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b3d12460d64bd448880826172ea91393f58ea1b2e44178ae343da1ca2023909a45b2ff1d3c7afc5efcb7b8f0657c8f99d2490d633638cfef45ae2f28ecb176c5
|
7
|
+
data.tar.gz: 0c8ba08ef084fe5881e8cb90b54ff1d9486abe2de905d21103346b4e445962dbe488c714aac8fe8d599319036d795fd0ac4cef9e9db83680b331e8106fe4e721
|
data/Gemfile.lock
CHANGED
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:
|
@@ -16,6 +18,46 @@ And then execute:
|
|
16
18
|
|
17
19
|
$ bundle install
|
18
20
|
|
21
|
+
## Features
|
22
|
+
|
23
|
+
### Automatic Package Finder
|
24
|
+
|
25
|
+
This gem will read `Gemfile` and find any "knows" gem in the dependency database and put the necessary package as a dependency for build and runtime.
|
26
|
+
|
27
|
+
That means you never need to know the actual package and don't need to write your Dockerfile by hand.
|
28
|
+
|
29
|
+
### Optimized Size
|
30
|
+
|
31
|
+
By the default, the base image is depend on `ruby:[VERSION]-alpine` which is minimal size for Ruby in most cases.
|
32
|
+
|
33
|
+
To let your image as small as possible, this gem uses multi-stage and strip useless artifacts while the c-extension compiling.
|
34
|
+
|
35
|
+
The final Rails image will be around 100MB and can be flexible to delivery to any environment.
|
36
|
+
|
37
|
+
> We suggest using `puma` as the webserver to avoid the extra dependency to keep the image small.
|
38
|
+
|
39
|
+
### Revision
|
40
|
+
|
41
|
+
To identity your image version, the default build argument `REVISION` will be configured by default.
|
42
|
+
|
43
|
+
You can add extra options when you are building images in your CI.
|
44
|
+
|
45
|
+
```yaml
|
46
|
+
# GitLab CI example
|
47
|
+
docker:rails:
|
48
|
+
extends: .docker
|
49
|
+
stage: package
|
50
|
+
script:
|
51
|
+
- docker build
|
52
|
+
--cache-from $RAILS_IMAGE:latest
|
53
|
+
--build-arg REVISION=${CI_COMMIT_SHORT_SHA}
|
54
|
+
--build-arg BUILDKIT_INLINE_CACHE=1
|
55
|
+
--tag $RAILS_IMAGE:$CI_COMMIT_REF_SLUG
|
56
|
+
--tag $RAILS_IMAGE:latest .
|
57
|
+
```
|
58
|
+
|
59
|
+
It will helpful for Sentry to detect the released version or use `<%= ENV['REVISION'] %>` to help you identify the current version.
|
60
|
+
|
19
61
|
## Usage
|
20
62
|
|
21
63
|
### Generate
|
@@ -26,9 +68,22 @@ To generate `Dockerfile` for current project
|
|
26
68
|
bundle exec boxing generate
|
27
69
|
```
|
28
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
|
+
|
29
81
|
## Roadmap
|
30
82
|
|
31
83
|
* [x] `Dockerfile` generator
|
84
|
+
* [x] `.gitignore` generator
|
85
|
+
* [x] Common ignore files
|
86
|
+
* [ ] Customizable ignore files
|
32
87
|
* [ ] Customize config file `config/boxing.rb`
|
33
88
|
* [ ] Entrypoint Detection
|
34
89
|
* [x] Openbox (Suggested)
|
@@ -37,12 +92,13 @@ bundle exec boxing generate
|
|
37
92
|
* [ ] Ruby
|
38
93
|
* [ ] Package Database
|
39
94
|
* [x] Built-in (Move to standalone repoistory in future)
|
40
|
-
* [
|
41
|
-
* [
|
95
|
+
* [x] Standalone Repoistory
|
96
|
+
* [x] Customize Source
|
42
97
|
* [ ] Base Image
|
43
98
|
* [x] Alpine
|
44
99
|
* [ ] Ubuntu
|
45
|
-
* [ ] Ruby Version
|
100
|
+
* [ ] Filter by Ruby Version
|
101
|
+
* [ ] Filter by Gem Version
|
46
102
|
|
47
103
|
## Development
|
48
104
|
|
data/lib/boxing/command.rb
CHANGED
@@ -21,7 +21,10 @@ 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)
|
27
|
+
template('templates/dockerignore.tt', '.dockerignore', context: context.to_binding)
|
25
28
|
end
|
26
29
|
|
27
30
|
private
|
@@ -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
|
data/lib/boxing/database.rb
CHANGED
@@ -9,12 +9,80 @@ module Boxing
|
|
9
9
|
# @since 0.1.0
|
10
10
|
class Database
|
11
11
|
class << self
|
12
|
-
#
|
12
|
+
# Check for the database exists
|
13
13
|
#
|
14
|
-
# @
|
15
|
-
|
16
|
-
|
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(
|
112
|
+
Dir.glob(File.join(@path, 'gems', name, '*.yml'), &block)
|
45
113
|
end
|
46
114
|
end
|
47
115
|
end
|
data/lib/boxing/version.rb
CHANGED
data/templates/Dockerfile.tt
CHANGED
@@ -29,6 +29,9 @@ 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
|
+
|
32
35
|
<%- end -%>
|
33
36
|
COPY --from=gem /usr/local/bundle/config /usr/local/bundle/config
|
34
37
|
COPY --from=gem /usr/local/bundle /usr/local/bundle
|
@@ -43,6 +46,7 @@ ENV RAILS_LOG_TO_STDOUT=true
|
|
43
46
|
ENV APP_ROOT=$APP_ROOT
|
44
47
|
|
45
48
|
COPY . ${APP_ROOT}
|
49
|
+
RUN echo $REVISION > ${SERVER_ROOT}/REVISION
|
46
50
|
|
47
51
|
# Apply Execute Permission
|
48
52
|
RUN adduser -h ${APP_ROOT} -D -s /bin/nologin ruby ruby && \
|
@@ -0,0 +1,33 @@
|
|
1
|
+
# Repo
|
2
|
+
.git/
|
3
|
+
|
4
|
+
# Docker
|
5
|
+
Dockerfile
|
6
|
+
docker-compose*.yml
|
7
|
+
|
8
|
+
# CI/CD
|
9
|
+
.github/
|
10
|
+
.cache/
|
11
|
+
coverage/
|
12
|
+
spec/
|
13
|
+
features/
|
14
|
+
.gitlab-ci.yml
|
15
|
+
.travis.yml
|
16
|
+
|
17
|
+
# Lint/Test
|
18
|
+
rspec.xml
|
19
|
+
.overcommit.yml
|
20
|
+
.rubocop*.yml
|
21
|
+
|
22
|
+
# Ruby
|
23
|
+
.bundle/
|
24
|
+
.env
|
25
|
+
.env*
|
26
|
+
|
27
|
+
# Rails
|
28
|
+
log/*
|
29
|
+
tmp/*
|
30
|
+
|
31
|
+
# Licensed
|
32
|
+
.licensed.yml
|
33
|
+
.licenses
|
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.1
|
4
|
+
version: 0.3.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-
|
11
|
+
date: 2021-12-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -57,21 +57,17 @@ 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
|
73
68
|
- lib/boxing/version.rb
|
74
69
|
- templates/Dockerfile.tt
|
70
|
+
- templates/dockerignore.tt
|
75
71
|
homepage: https://github.com/elct9620/boxing
|
76
72
|
licenses: []
|
77
73
|
metadata:
|