railsdock 0.2.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +4 -0
- data/Gemfile.lock +1 -1
- data/example-app/.browserslistrc +1 -0
- data/example-app/.gitignore +31 -0
- data/example-app/.ruby-version +1 -0
- data/example-app/Gemfile +46 -0
- data/example-app/Gemfile.lock +201 -0
- data/example-app/README.md +24 -0
- data/example-app/Rakefile +6 -0
- data/example-app/app/assets/config/manifest.js +2 -0
- data/example-app/app/assets/images/.keep +0 -0
- data/example-app/app/assets/stylesheets/application.css +15 -0
- data/example-app/app/channels/application_cable/channel.rb +4 -0
- data/example-app/app/channels/application_cable/connection.rb +4 -0
- data/example-app/app/controllers/application_controller.rb +2 -0
- data/example-app/app/controllers/concerns/.keep +0 -0
- data/example-app/app/helpers/application_helper.rb +2 -0
- data/example-app/app/javascript/channels/consumer.js +6 -0
- data/example-app/app/javascript/channels/index.js +5 -0
- data/example-app/app/javascript/packs/application.js +17 -0
- data/example-app/app/jobs/application_job.rb +7 -0
- data/example-app/app/mailers/application_mailer.rb +4 -0
- data/example-app/app/models/application_record.rb +3 -0
- data/example-app/app/models/concerns/.keep +0 -0
- data/example-app/app/views/layouts/application.html.erb +15 -0
- data/example-app/app/views/layouts/mailer.html.erb +13 -0
- data/example-app/app/views/layouts/mailer.text.erb +1 -0
- data/example-app/babel.config.js +72 -0
- data/example-app/bin/bundle +105 -0
- data/example-app/bin/rails +9 -0
- data/example-app/bin/rake +9 -0
- data/example-app/bin/setup +36 -0
- data/example-app/bin/spring +17 -0
- data/example-app/bin/webpack +18 -0
- data/example-app/bin/webpack-dev-server +18 -0
- data/example-app/bin/yarn +11 -0
- data/example-app/config/application.rb +35 -0
- data/example-app/config/boot.rb +4 -0
- data/example-app/config/cable.yml +10 -0
- data/example-app/config/credentials.yml.enc +1 -0
- data/example-app/config/database.yml +18 -0
- data/example-app/config/environment.rb +5 -0
- data/example-app/config/environments/development.rb +62 -0
- data/example-app/config/environments/production.rb +112 -0
- data/example-app/config/environments/test.rb +48 -0
- data/example-app/config/initializers/application_controller_renderer.rb +8 -0
- data/example-app/config/initializers/assets.rb +14 -0
- data/example-app/config/initializers/backtrace_silencers.rb +7 -0
- data/example-app/config/initializers/content_security_policy.rb +30 -0
- data/example-app/config/initializers/cookies_serializer.rb +5 -0
- data/example-app/config/initializers/filter_parameter_logging.rb +4 -0
- data/example-app/config/initializers/inflections.rb +16 -0
- data/example-app/config/initializers/mime_types.rb +4 -0
- data/example-app/config/initializers/wrap_parameters.rb +14 -0
- data/example-app/config/locales/en.yml +33 -0
- data/example-app/config/puma.rb +38 -0
- data/example-app/config/routes.rb +3 -0
- data/example-app/config/spring.rb +6 -0
- data/example-app/config/storage.yml +34 -0
- data/example-app/config/webpack/development.js +5 -0
- data/example-app/config/webpack/environment.js +3 -0
- data/example-app/config/webpack/production.js +5 -0
- data/example-app/config/webpack/test.js +5 -0
- data/example-app/config/webpacker.yml +96 -0
- data/example-app/config.ru +5 -0
- data/example-app/db/schema.rb +18 -0
- data/example-app/db/seeds.rb +7 -0
- data/example-app/lib/assets/.keep +0 -0
- data/example-app/lib/tasks/.keep +0 -0
- data/example-app/log/.keep +0 -0
- data/example-app/package.json +15 -0
- data/example-app/postcss.config.js +12 -0
- data/example-app/public/404.html +67 -0
- data/example-app/public/422.html +67 -0
- data/example-app/public/500.html +66 -0
- data/example-app/public/apple-touch-icon-precomposed.png +0 -0
- data/example-app/public/apple-touch-icon.png +0 -0
- data/example-app/public/favicon.ico +0 -0
- data/example-app/public/robots.txt +1 -0
- data/example-app/storage/.keep +0 -0
- data/example-app/tmp/.keep +0 -0
- data/example-app/vendor/.keep +0 -0
- data/example-app/yarn.lock +7721 -0
- data/lib/railsdock/commands/install.rb +11 -3
- data/lib/railsdock/templates/install/default/Dockerfile +10 -4
- data/lib/railsdock/templates/install/default/default.env.erb +5 -18
- data/lib/railsdock/templates/install/default/docker-compose.yml.erb +8 -18
- data/lib/railsdock/templates/install/default/{dev-entrypoint → entrypoint.sh} +4 -4
- data/lib/railsdock/templates/install/postgres/docker-compose.yml.erb +2 -0
- data/lib/railsdock/templates/install/postgres/postgres.env +0 -3
- data/lib/railsdock/version.rb +1 -1
- metadata +85 -5
- data/lib/railsdock/templates/install/default/docker-compose.mac.yml +0 -7
@@ -2,6 +2,7 @@
|
|
2
2
|
|
3
3
|
require 'ostruct'
|
4
4
|
require 'erb'
|
5
|
+
require 'bundler'
|
5
6
|
require_relative '../command'
|
6
7
|
require_relative '../logo'
|
7
8
|
|
@@ -38,7 +39,8 @@ module Railsdock
|
|
38
39
|
app_name: options[:app_name] || get_app_name,
|
39
40
|
is_windows?: platform.windows?,
|
40
41
|
is_mac?: platform.mac?,
|
41
|
-
uid: cmd.run('id -u').out.chomp
|
42
|
+
uid: cmd.run('id -u').out.chomp,
|
43
|
+
ruby_version: get_ruby_version
|
42
44
|
)
|
43
45
|
end
|
44
46
|
|
@@ -58,7 +60,7 @@ module Railsdock
|
|
58
60
|
inject_db_script_into_entrypoint(service)
|
59
61
|
end
|
60
62
|
end
|
61
|
-
cmd.run('chmod +x ./
|
63
|
+
cmd.run('chmod +x ./docker/ruby/entrypoint.sh')
|
62
64
|
output.puts POST_INSTALL_MESSAGE
|
63
65
|
end
|
64
66
|
|
@@ -68,12 +70,16 @@ module Railsdock
|
|
68
70
|
::File.open('./config/application.rb').read.match(/module (.+)\s/)[1].downcase
|
69
71
|
end
|
70
72
|
|
73
|
+
def get_ruby_version
|
74
|
+
::Bundler.definition.ruby_version.versions[0] || RUBY_VERSION
|
75
|
+
end
|
76
|
+
|
71
77
|
def copy_db_yml(erb_file)
|
72
78
|
file.copy_file(erb_file, './config/database.yml', context: @variables)
|
73
79
|
end
|
74
80
|
|
75
81
|
def inject_db_script_into_entrypoint(service)
|
76
|
-
file.inject_into_file('./
|
82
|
+
file.inject_into_file('./docker/ruby/entrypoint.sh', after: "echo \"DB is not ready, sleeping...\"\n") do
|
77
83
|
<<~BASH
|
78
84
|
until nc -vz #{service} #{OPTIONS_HASH[:database][:default_port][service]}; do
|
79
85
|
sleep 1
|
@@ -148,6 +154,8 @@ module Railsdock
|
|
148
154
|
case File.basename(path)
|
149
155
|
when 'Dockerfile'
|
150
156
|
file.copy_file(path, "#{@variables.dockerfile_dir}ruby/Dockerfile", context: @variables)
|
157
|
+
when 'entrypoint.sh'
|
158
|
+
file.copy_file(path, "#{@variables.dockerfile_dir}ruby/entrypoint.sh", context: @variables)
|
151
159
|
when 'docker-compose.yml.erb'
|
152
160
|
file.copy_file(path, './docker-compose.yml', context: @variables)
|
153
161
|
when 'default.env.erb'
|
@@ -10,7 +10,7 @@ ARG DEBIAN_FRONTEND=noninteractive
|
|
10
10
|
# Base Software Install
|
11
11
|
###############################################################################
|
12
12
|
|
13
|
-
ARG RAILSDOCK_NODE_VERSION=
|
13
|
+
ARG RAILSDOCK_NODE_VERSION=12
|
14
14
|
|
15
15
|
RUN curl -sL https://deb.nodesource.com/setup_$RAILSDOCK_NODE_VERSION.x | bash -
|
16
16
|
|
@@ -50,8 +50,10 @@ RUN groupadd -g $RUBY_GID $USER && \
|
|
50
50
|
|
51
51
|
ENV LANG C.UTF-8
|
52
52
|
|
53
|
+
# Update Rubygems to latest
|
54
|
+
RUN gem update --system
|
55
|
+
|
53
56
|
# Point Bundler at /gems. This will cause Bundler to re-use gems that have already been installed on the gems volume
|
54
|
-
ENV BUNDLE_PATH /gems
|
55
57
|
ENV BUNDLE_HOME /gems
|
56
58
|
|
57
59
|
# Increase how many threads Bundler uses when installing. Optional!
|
@@ -67,7 +69,9 @@ ENV GEM_HOME /gems
|
|
67
69
|
ENV GEM_PATH /gems
|
68
70
|
|
69
71
|
# Add /gems/bin to the path so any installed gem binaries are runnable from bash.
|
70
|
-
ENV PATH /gems/bin:$PATH
|
72
|
+
ENV PATH ${GEM_HOME}/bin:${GEM_HOME}/gems/bin:$PATH
|
73
|
+
|
74
|
+
RUN unset BUNDLE_PATH && unset BUNDLE_BIN
|
71
75
|
|
72
76
|
###############################################################################
|
73
77
|
# Optional Software Install
|
@@ -89,11 +93,13 @@ RUN if [ "$INSTALL_PG_CLIENT" = true ]; then \
|
|
89
93
|
###############################################################################
|
90
94
|
|
91
95
|
RUN mkdir -p "$GEM_HOME" && chown $USER:$USER "$GEM_HOME"
|
96
|
+
RUN mkdir -p /app && chown $USER:$USER /app
|
92
97
|
|
93
|
-
RUN mkdir -p /app
|
94
98
|
WORKDIR /app
|
95
99
|
|
96
100
|
RUN mkdir -p node_modules && chown $USER:$USER node_modules
|
101
|
+
RUN mkdir -p public/packs && chown $USER:$USER public/packs
|
102
|
+
RUN mkdir -p tmp/cache && chown $USER:$USER tmp/cache
|
97
103
|
|
98
104
|
USER $USER
|
99
105
|
|
@@ -2,23 +2,10 @@
|
|
2
2
|
############################# General Setup ###################################
|
3
3
|
###############################################################################
|
4
4
|
|
5
|
-
### Paths #####################################################################
|
6
|
-
|
7
|
-
# Point to the path of your applications code on your host
|
8
|
-
APP_CODE_PATH_HOST=../
|
9
|
-
|
10
|
-
# Point to where the `APP_CODE_PATH_HOST` should be in the container.
|
11
|
-
APP_CODE_PATH_CONTAINER=/app
|
12
|
-
|
13
|
-
### DRIVERS ###################################################################
|
14
|
-
|
15
|
-
# All volumes driver
|
16
|
-
VOLUMES_DRIVER=local
|
17
|
-
|
18
5
|
### Docker compose files ######################################################
|
19
6
|
|
20
7
|
# Select which docker-compose files to include. If using an override append `:docker-compose.example.yml` at the end
|
21
|
-
COMPOSE_FILE=docker-compose.yml
|
8
|
+
COMPOSE_FILE=docker-compose.yml
|
22
9
|
|
23
10
|
# Change the separator from : to ; on Windows
|
24
11
|
COMPOSE_PATH_SEPARATOR=<%= is_windows? ? ';' : ':' %>
|
@@ -32,13 +19,13 @@ COMPOSE_PROJECT_NAME=<%= app_name %>
|
|
32
19
|
|
33
20
|
|
34
21
|
### RUBY ######################################################################
|
35
|
-
# Select a Ruby Version of the Ruby container. Accepted values: 2.2-2.
|
22
|
+
# Select a Ruby Version of the Ruby container. Accepted values: 2.2.x-2.7.x
|
36
23
|
|
37
|
-
RAILSDOCK_RUBY_VERSION
|
24
|
+
RAILSDOCK_RUBY_VERSION=<%= ruby_version %>
|
38
25
|
BUNDLE_JOBS=10
|
39
26
|
BUNDLE_RETRY=3
|
40
27
|
RAILS_SERVER_HOST_PORT=3000
|
41
28
|
RUBY_UID=<%= uid %>
|
42
29
|
RUBY_GID=<%= uid %>
|
43
|
-
# Select a Node Version for the Ruby container. Accepted values: 8-
|
44
|
-
RAILSDOCK_NODE_VERSION=
|
30
|
+
# Select a Node Version for the Ruby container. Accepted values: 8-13
|
31
|
+
RAILSDOCK_NODE_VERSION=12
|
@@ -6,10 +6,12 @@ x-ruby: &ruby-base
|
|
6
6
|
args:
|
7
7
|
- RAILSDOCK_RUBY_VERSION=${RAILSDOCK_RUBY_VERSION}
|
8
8
|
- RAILSDOCK_NODE_VERSION=${RAILSDOCK_NODE_VERSION}
|
9
|
+
- RAILSDOCK_BUNDLE_JOBS=${BUNDLE_JOBS}
|
10
|
+
- RAILSDOCK_BUNDLE_RETRY=${BUNDLE_RETRY}
|
9
11
|
- RUBY_UID=${RUBY_UID}
|
10
12
|
- RUBY_GID=${RUBY_GID}
|
11
13
|
volumes:
|
12
|
-
- .:/app
|
14
|
+
- .:/app:cached
|
13
15
|
- gems:/gems
|
14
16
|
- node_modules:/app/node_modules
|
15
17
|
- packs:/app/public/packs
|
@@ -24,26 +26,14 @@ x-ruby: &ruby-base
|
|
24
26
|
volumes:
|
25
27
|
gems:
|
26
28
|
node_modules:
|
29
|
+
packs:
|
30
|
+
rails_cache:
|
27
31
|
|
28
32
|
services:
|
29
33
|
|
30
34
|
rails:
|
31
35
|
<<: *ruby-base
|
32
|
-
|
33
|
-
|
34
|
-
args:
|
35
|
-
- RAILSDOCK_BUNDLE_JOBS=${BUNDLE_JOBS}
|
36
|
-
- RAILSDOCK_BUNDLE_RETRY=${BUNDLE_RETRY}
|
37
|
-
environment:
|
38
|
-
- DATABASE_USER=${DATABASE_USER}
|
39
|
-
- DATABASE_PASSWORD=${DATABASE_PASSWORD}
|
40
|
-
- DATABASE_HOST=${DATABASE_HOST}
|
41
|
-
volumes:
|
42
|
-
- ${APP_CODE_PATH_HOST}:${APP_CODE_PATH_CONTAINER}
|
43
|
-
- gems:/gems
|
44
|
-
- node_modules:${APP_CODE_PATH_CONTAINER}/node_modules
|
36
|
+
command: rails server -p 3000 -b '0.0.0.0'
|
37
|
+
entrypoint: ./docker/ruby/entrypoint.sh
|
45
38
|
ports:
|
46
|
-
- "${RAILS_SERVER_HOST_PORT}:3000"
|
47
|
-
user: ruby
|
48
|
-
tty: true
|
49
|
-
stdin_open: true
|
39
|
+
- "${RAILS_SERVER_HOST_PORT}:3000"
|
@@ -22,10 +22,10 @@ echo "DB is not ready, sleeping..."
|
|
22
22
|
echo "DB is ready, starting Rails."
|
23
23
|
|
24
24
|
# 4: Specify a default command, in case it wasn't issued:
|
25
|
-
if [ -z "$1" ]; then set -- rails server -p 3000 -b 0.0.0.0 "$@"; fi
|
25
|
+
if [ -z "$1" ]; then set -- bundle exec rails server -p 3000 -b 0.0.0.0 "$@"; fi
|
26
26
|
|
27
27
|
# 5: Run the checks only if the app code is going to be executed:
|
28
|
-
if [[ "$
|
28
|
+
if [[ "$3" = "rails" ]]
|
29
29
|
then
|
30
30
|
# Clean up any orphaned lock file
|
31
31
|
unlock_setup
|
@@ -49,7 +49,7 @@ then
|
|
49
49
|
# check if the docker host is running on mac or windows
|
50
50
|
if ! check_host; then
|
51
51
|
HOST_IP=$(ip route | awk 'NR==1 {print $3}')
|
52
|
-
echo "$HOST_IP $HOST_DOMAIN"
|
52
|
+
echo "$HOST_IP $HOST_DOMAIN" | sudo tee -a /etc/hosts > /dev/null
|
53
53
|
fi
|
54
54
|
|
55
55
|
# 10: 'Unlock' the setup process:
|
@@ -58,7 +58,7 @@ then
|
|
58
58
|
# 11: If the command to execute is 'rails server', then we must remove any
|
59
59
|
# pid file present. Suddenly killing and removing app containers might leave
|
60
60
|
# this file, and prevent rails from starting-up if present:
|
61
|
-
if [[ "$
|
61
|
+
if [[ "$4" = "s" || "$4" = "server" ]]; then rm -rf /app/tmp/pids/server.pid; fi
|
62
62
|
fi
|
63
63
|
|
64
64
|
# 10: Execute the given or default command:
|
data/lib/railsdock/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: railsdock
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kyle Boe
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: exe
|
11
11
|
cert_chain: []
|
12
|
-
date: 2020-05-
|
12
|
+
date: 2020-05-22 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: railties
|
@@ -221,6 +221,87 @@ files:
|
|
221
221
|
- Rakefile
|
222
222
|
- bin/console
|
223
223
|
- bin/setup
|
224
|
+
- example-app/.browserslistrc
|
225
|
+
- example-app/.gitignore
|
226
|
+
- example-app/.ruby-version
|
227
|
+
- example-app/Gemfile
|
228
|
+
- example-app/Gemfile.lock
|
229
|
+
- example-app/README.md
|
230
|
+
- example-app/Rakefile
|
231
|
+
- example-app/app/assets/config/manifest.js
|
232
|
+
- example-app/app/assets/images/.keep
|
233
|
+
- example-app/app/assets/stylesheets/application.css
|
234
|
+
- example-app/app/channels/application_cable/channel.rb
|
235
|
+
- example-app/app/channels/application_cable/connection.rb
|
236
|
+
- example-app/app/controllers/application_controller.rb
|
237
|
+
- example-app/app/controllers/concerns/.keep
|
238
|
+
- example-app/app/helpers/application_helper.rb
|
239
|
+
- example-app/app/javascript/channels/consumer.js
|
240
|
+
- example-app/app/javascript/channels/index.js
|
241
|
+
- example-app/app/javascript/packs/application.js
|
242
|
+
- example-app/app/jobs/application_job.rb
|
243
|
+
- example-app/app/mailers/application_mailer.rb
|
244
|
+
- example-app/app/models/application_record.rb
|
245
|
+
- example-app/app/models/concerns/.keep
|
246
|
+
- example-app/app/views/layouts/application.html.erb
|
247
|
+
- example-app/app/views/layouts/mailer.html.erb
|
248
|
+
- example-app/app/views/layouts/mailer.text.erb
|
249
|
+
- example-app/babel.config.js
|
250
|
+
- example-app/bin/bundle
|
251
|
+
- example-app/bin/rails
|
252
|
+
- example-app/bin/rake
|
253
|
+
- example-app/bin/setup
|
254
|
+
- example-app/bin/spring
|
255
|
+
- example-app/bin/webpack
|
256
|
+
- example-app/bin/webpack-dev-server
|
257
|
+
- example-app/bin/yarn
|
258
|
+
- example-app/config.ru
|
259
|
+
- example-app/config/application.rb
|
260
|
+
- example-app/config/boot.rb
|
261
|
+
- example-app/config/cable.yml
|
262
|
+
- example-app/config/credentials.yml.enc
|
263
|
+
- example-app/config/database.yml
|
264
|
+
- example-app/config/environment.rb
|
265
|
+
- example-app/config/environments/development.rb
|
266
|
+
- example-app/config/environments/production.rb
|
267
|
+
- example-app/config/environments/test.rb
|
268
|
+
- example-app/config/initializers/application_controller_renderer.rb
|
269
|
+
- example-app/config/initializers/assets.rb
|
270
|
+
- example-app/config/initializers/backtrace_silencers.rb
|
271
|
+
- example-app/config/initializers/content_security_policy.rb
|
272
|
+
- example-app/config/initializers/cookies_serializer.rb
|
273
|
+
- example-app/config/initializers/filter_parameter_logging.rb
|
274
|
+
- example-app/config/initializers/inflections.rb
|
275
|
+
- example-app/config/initializers/mime_types.rb
|
276
|
+
- example-app/config/initializers/wrap_parameters.rb
|
277
|
+
- example-app/config/locales/en.yml
|
278
|
+
- example-app/config/puma.rb
|
279
|
+
- example-app/config/routes.rb
|
280
|
+
- example-app/config/spring.rb
|
281
|
+
- example-app/config/storage.yml
|
282
|
+
- example-app/config/webpack/development.js
|
283
|
+
- example-app/config/webpack/environment.js
|
284
|
+
- example-app/config/webpack/production.js
|
285
|
+
- example-app/config/webpack/test.js
|
286
|
+
- example-app/config/webpacker.yml
|
287
|
+
- example-app/db/schema.rb
|
288
|
+
- example-app/db/seeds.rb
|
289
|
+
- example-app/lib/assets/.keep
|
290
|
+
- example-app/lib/tasks/.keep
|
291
|
+
- example-app/log/.keep
|
292
|
+
- example-app/package.json
|
293
|
+
- example-app/postcss.config.js
|
294
|
+
- example-app/public/404.html
|
295
|
+
- example-app/public/422.html
|
296
|
+
- example-app/public/500.html
|
297
|
+
- example-app/public/apple-touch-icon-precomposed.png
|
298
|
+
- example-app/public/apple-touch-icon.png
|
299
|
+
- example-app/public/favicon.ico
|
300
|
+
- example-app/public/robots.txt
|
301
|
+
- example-app/storage/.keep
|
302
|
+
- example-app/tmp/.keep
|
303
|
+
- example-app/vendor/.keep
|
304
|
+
- example-app/yarn.lock
|
224
305
|
- exe/railsdock
|
225
306
|
- ext/railsdock/extconf.rb
|
226
307
|
- ext/railsdock/railsdock.c
|
@@ -232,9 +313,8 @@ files:
|
|
232
313
|
- lib/railsdock/logo.rb
|
233
314
|
- lib/railsdock/templates/install/default/Dockerfile
|
234
315
|
- lib/railsdock/templates/install/default/default.env.erb
|
235
|
-
- lib/railsdock/templates/install/default/dev-entrypoint
|
236
|
-
- lib/railsdock/templates/install/default/docker-compose.mac.yml
|
237
316
|
- lib/railsdock/templates/install/default/docker-compose.yml.erb
|
317
|
+
- lib/railsdock/templates/install/default/entrypoint.sh
|
238
318
|
- lib/railsdock/templates/install/memcached/Dockerfile
|
239
319
|
- lib/railsdock/templates/install/memcached/docker-compose.yml.erb
|
240
320
|
- lib/railsdock/templates/install/memcached/memcached.env
|
@@ -274,7 +354,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
274
354
|
- !ruby/object:Gem::Version
|
275
355
|
version: '0'
|
276
356
|
requirements: []
|
277
|
-
rubygems_version: 3.
|
357
|
+
rubygems_version: 3.1.3
|
278
358
|
signing_key:
|
279
359
|
specification_version: 4
|
280
360
|
summary: Docker-ize your Rails project.
|