dockhand 0.1.0 → 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 +4 -4
- data/CHANGELOG.md +3 -0
- data/Gemfile +1 -1
- data/README.md +130 -2
- data/lib/dockhand/version.rb +1 -1
- metadata +4 -9
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: fa42658ae6a6ea4f1be74a573fcafc43696e7573d4752df296c643973906d89a
|
|
4
|
+
data.tar.gz: bfc3365a8e382a3f7ac8a449d3bdda69b181b27e38346f3a9458b74db70afa91
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 5907d0220a5bb352e6ec058cd37320a960b57bebbf46df0749e0fe619641366e1df0c70308e3f0a586b206a92747409ff8a367ed30f15c58d91072de5a401119
|
|
7
|
+
data.tar.gz: 0e031a75bbcdb07623478287040aa429604b7a83097043dfdbc251cf54a592dfa1aa99f33ef73bfb87d91c65d3841ee347da0c31e4b2cff47305db001b73c1e7
|
data/CHANGELOG.md
CHANGED
data/Gemfile
CHANGED
data/README.md
CHANGED
|
@@ -1,11 +1,139 @@
|
|
|
1
1
|
# dockhand
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
`dockhand` is a collection of helper commands that you can run *inside* a Docker
|
|
4
|
+
container to set up a Rails application.
|
|
5
|
+
|
|
6
|
+
```console
|
|
7
|
+
$ dockhand --help
|
|
8
|
+
Commands:
|
|
9
|
+
dockhand help [COMMAND] # Describe available commands or one specific command.
|
|
10
|
+
dockhand install-gems # Install gems with Bundler.
|
|
11
|
+
dockhand install-node # Install Node.js.
|
|
12
|
+
dockhand install-node-modules # Install Node.js modules using Yarn, NPM, or PNPM.
|
|
13
|
+
dockhand install-packages [PACKAGES...] # Install apt packages.
|
|
14
|
+
dockhand prepare-rails-app # Precompile assets, precompile code with Bootsnap, and normalize binstubs.
|
|
15
|
+
dockhand rails-entrypoint # Entrypoint for a Rails application.
|
|
16
|
+
dockhand transmute-to-artifacts [PATHS...] # Move files and directories to an artifacts directory, and replace the originals with symlinks.
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
For example, in the following `Dockerfile`:
|
|
21
|
+
|
|
22
|
+
```dockerfile
|
|
23
|
+
FROM ruby:3.4.0-slim
|
|
24
|
+
|
|
25
|
+
RUN gem install dockhand
|
|
26
|
+
|
|
27
|
+
WORKDIR /rails
|
|
28
|
+
|
|
29
|
+
COPY Gemfile Gemfile.lock .
|
|
30
|
+
RUN dockhand install-packages --buildtime --gem-buildtime --gem-runtime --clean \
|
|
31
|
+
&& dockhand install-gems --clean
|
|
32
|
+
|
|
33
|
+
COPY . .
|
|
34
|
+
RUN dockhand prepare-rails-app --clean
|
|
35
|
+
|
|
36
|
+
ENV RAILS_ENV=production
|
|
37
|
+
ENTRYPOINT ["dockhand", "rails-entrypoint"]
|
|
38
|
+
CMD ["bin/rails", "server"]
|
|
39
|
+
EXPOSE 3000
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
* `dockhand install-packages ...` installs the apt packages needed for common
|
|
43
|
+
gems in the `Gemfile`, such as `libsqlite3-0` if using the `sqlite3` gem or
|
|
44
|
+
`postgresql-client` if using the `pg` gem. Then it cleans up the apt cache
|
|
45
|
+
directories so the image won't contain unnecessary files.
|
|
46
|
+
|
|
47
|
+
* `dockhand install-gems ...` installs the gems specified by `Gemfile.lock`,
|
|
48
|
+
treating the lock file as frozen to ensure reproducible builds. Then it
|
|
49
|
+
cleans up Bundler's cache so the image won't contain unnecessary files.
|
|
50
|
+
|
|
51
|
+
* `dockhand prepare-rails-app ...` precompiles code with [`bootsnap`][],
|
|
52
|
+
precompiles assets with a dummy `SECRET_KEY_BASE`, and fixes binstubs in
|
|
53
|
+
`bin/` for Windows users. Then it cleans up the assets precompilation cache
|
|
54
|
+
so the image won't contain unnecessary files.
|
|
55
|
+
|
|
56
|
+
[`bootsnap`]: https://rubygems.org/gems/bootsnap
|
|
57
|
+
|
|
58
|
+
* `dockhand rails-entrypoint` injects a call to `bin/rails db:prepare` if the
|
|
59
|
+
given command is `bin/rails server` (or an alias thereof).
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
As another example, the following `Dockerfile` uses a [multi-stage build][] and
|
|
63
|
+
precompiles assets using Node.js:
|
|
64
|
+
|
|
65
|
+
```dockerfile
|
|
66
|
+
# Builder stage
|
|
67
|
+
FROM ruby:3.4.0-slim as builder
|
|
68
|
+
|
|
69
|
+
RUN gem install dockhand
|
|
70
|
+
|
|
71
|
+
WORKDIR /artifacts/rails
|
|
72
|
+
|
|
73
|
+
COPY Gemfile Gemfile.lock .
|
|
74
|
+
RUN dockhand install-packages --buildtime --gem-buildtime \
|
|
75
|
+
&& dockhand install-gems --clean \
|
|
76
|
+
&& dockhand transmute-to-artifacts $GEM_HOME
|
|
77
|
+
|
|
78
|
+
COPY .node-version package.json yarn.lock .
|
|
79
|
+
RUN dockhand install-node \
|
|
80
|
+
&& dockhand install-node-modules
|
|
81
|
+
|
|
82
|
+
COPY . .
|
|
83
|
+
RUN dockhand prepare-rails-app --clean
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
# Application stage
|
|
87
|
+
FROM ruby:3.4.0-slim
|
|
88
|
+
|
|
89
|
+
RUN gem install dockhand
|
|
90
|
+
|
|
91
|
+
WORKDIR /rails
|
|
92
|
+
|
|
93
|
+
COPY Gemfile Gemfile.lock .
|
|
94
|
+
RUN dockhand install-packages --gem-runtime --clean
|
|
95
|
+
|
|
96
|
+
COPY --from=builder /artifacts /
|
|
97
|
+
|
|
98
|
+
ENV RAILS_ENV=production
|
|
99
|
+
ENTRYPOINT ["dockhand", "rails-entrypoint"]
|
|
100
|
+
CMD ["bin/rails", "server"]
|
|
101
|
+
EXPOSE 3000
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
* `dockhand transmute-to-artifacts ...` moves `/usr/local/bundle` (`$GEM_HOME`)
|
|
105
|
+
to `/artifacts/usr/local/bundle` and creates a symlink at `/usr/local/bundle`
|
|
106
|
+
that points to `/artifacts/usr/local/bundle`. This makes it easy to copy gems
|
|
107
|
+
as artifacts from the builder stage to the final application stage, while
|
|
108
|
+
still allowing subsequent commands in the builder stage to use those gems.
|
|
109
|
+
|
|
110
|
+
* `dockhand install-node` installs the appropriate version of Node.js based on
|
|
111
|
+
`.node-version`. If you don't provide a `.node-version` file, it will try
|
|
112
|
+
to choose a version based on the `engines.node` value in `package.json`.
|
|
113
|
+
|
|
114
|
+
* `dockhand install-node-modules` installs Node.js modules specified by
|
|
115
|
+
`yarn.lock`, using the appropriate version of Yarn and treating the lock file
|
|
116
|
+
as frozen to ensure reproducible builds. It also supports NPM and PNPM lock
|
|
117
|
+
files.
|
|
118
|
+
|
|
119
|
+
[multi-stage build]: https://docs.docker.com/build/building/multi-stage/
|
|
120
|
+
|
|
121
|
+
|
|
122
|
+
***If you're looking for a more turn-key solution for your application's
|
|
123
|
+
`Dockerfile`, including reduced build times using mounted caches, check out
|
|
124
|
+
[`railbarge`][] which is built on `dockhand`.***
|
|
125
|
+
|
|
126
|
+
[`railbarge`]: https://github.com/jonathanhefner/railbarge
|
|
4
127
|
|
|
5
128
|
|
|
6
129
|
## Installation
|
|
7
130
|
|
|
8
|
-
Install the [`dockhand` gem](https://rubygems.org/gems/dockhand)
|
|
131
|
+
Install the [`dockhand` gem](https://rubygems.org/gems/dockhand) in your
|
|
132
|
+
`Dockerfile`:
|
|
133
|
+
|
|
134
|
+
```dockerfile
|
|
135
|
+
RUN gem install dockhand
|
|
136
|
+
```
|
|
9
137
|
|
|
10
138
|
|
|
11
139
|
## Contributing
|
data/lib/dockhand/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: dockhand
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.2.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Jonathan Hefner
|
|
8
|
-
autorequire:
|
|
9
8
|
bindir: exe
|
|
10
9
|
cert_chain: []
|
|
11
|
-
date:
|
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
12
11
|
dependencies:
|
|
13
12
|
- !ruby/object:Gem::Dependency
|
|
14
13
|
name: thor
|
|
@@ -24,7 +23,6 @@ dependencies:
|
|
|
24
23
|
- - "~>"
|
|
25
24
|
- !ruby/object:Gem::Version
|
|
26
25
|
version: '1.2'
|
|
27
|
-
description:
|
|
28
26
|
email:
|
|
29
27
|
- jonathan@hefner.pro
|
|
30
28
|
executables:
|
|
@@ -45,10 +43,8 @@ homepage: https://github.com/jonathanhefner/dockhand
|
|
|
45
43
|
licenses:
|
|
46
44
|
- MIT
|
|
47
45
|
metadata:
|
|
48
|
-
homepage_uri: https://github.com/jonathanhefner/dockhand
|
|
49
46
|
source_code_uri: https://github.com/jonathanhefner/dockhand
|
|
50
47
|
changelog_uri: https://github.com/jonathanhefner/dockhand/blob/HEAD/CHANGELOG.md
|
|
51
|
-
post_install_message:
|
|
52
48
|
rdoc_options: []
|
|
53
49
|
require_paths:
|
|
54
50
|
- lib
|
|
@@ -56,15 +52,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
56
52
|
requirements:
|
|
57
53
|
- - ">="
|
|
58
54
|
- !ruby/object:Gem::Version
|
|
59
|
-
version: '
|
|
55
|
+
version: '3.4'
|
|
60
56
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
61
57
|
requirements:
|
|
62
58
|
- - ">="
|
|
63
59
|
- !ruby/object:Gem::Version
|
|
64
60
|
version: '0'
|
|
65
61
|
requirements: []
|
|
66
|
-
rubygems_version:
|
|
67
|
-
signing_key:
|
|
62
|
+
rubygems_version: 4.0.10
|
|
68
63
|
specification_version: 4
|
|
69
64
|
summary: Toolkit for building Rails app Docker images
|
|
70
65
|
test_files: []
|