lib/generators/dockerfile_generator.rb in dockerfile-rails-0.0.2 vs lib/generators/dockerfile_generator.rb in dockerfile-rails-0.1.0
- old
+ new
@@ -8,10 +8,13 @@
desc: 'use build cache to speed up installs'
class_option :parallel, type: :boolean, default: false,
desc: 'use build stages to install gems and node modules in parallel'
+ class_option :compose, type: :boolean, default: false,
+ desc: 'generate a docker-compose.yml file'
+
class_option :redit, type: :boolean, default: false,
desc: 'include redis libraries'
class_option :sqlite3, aliases: '--sqlite', type: :boolean, default: false,
desc: 'include sqlite3 libraries'
@@ -32,19 +35,25 @@
template 'node-version.erb', '.node-version' if using_node?
template 'docker-entrypoint.erb', 'bin/docker-entrypoint'
chmod "bin/docker-entrypoint", 0755 & ~File.umask, verbose: false
+
+ template 'docker-compose.yml.erb', 'docker-compose.yml'
end
private
def using_node?
return @using_node if @using_node != nil
@using_node = File.exist? 'package.json'
end
+ def using_redis?
+ options.redis? or @redis
+ end
+
def parallel?
using_node? && options.parallel
end
def keeps?
@@ -59,12 +68,15 @@
# add databases: sqlite3, postgres, mysql
packages << 'pkg-config' if options.sqlite3? or @sqlite3
packages << 'libpq-dev' if options.postgresql? or @postgresql
packages << 'default-libmysqlclient-dev' if options.mysql or @mysql
+ # add git if needed to install gems
+ packages << 'git' if @git
+
# add redis in case Action Cable, caching, or sidekiq are added later
- packages << "redis" if options.redis? or @redis
+ packages << "redis" if using_redis?
# ActiveStorage preview support
packages << "libvips" if @gemfile.include? 'ruby-vips'
# node support, including support for building native modules
@@ -101,11 +113,11 @@
packages << 'libsqlite3-0' if options.sqlite3? or @sqlite3
packages << 'postgresql-client' if options.postgresql? or @postgresql
packages << 'default-mysql-client' if options.mysql or @mysql
# add redis in case Action Cable, caching, or sidekiq are added later
- packages << "redis" if options.redis? or @redis
+ packages << "redis" if using_redis?
# ActiveStorage preview support
packages << "libvips" if @gemfile.include? 'ruby-vips'
packages.sort
@@ -136,9 +148,19 @@
unless Dir["bin/*"].all? { |file| File.executable? file }
binfixups.unshift "chmod +x bin/*"
end
binfixups
+ end
+
+ def deploy_database
+ if options.postgresql? or @postgresql
+ 'postgresql'
+ elsif options.mysql or @mysql
+ 'mysql'
+ else
+ 'sqlite3'
+ end
end
def node_version
using_node? and `node --version`[/\d+\.\d+\.\d+/]
rescue
\ No newline at end of file