lib/generators/dockerfile_generator.rb in dockerfile-rails-0.5.1 vs lib/generators/dockerfile_generator.rb in dockerfile-rails-0.5.2

- old
+ new

@@ -85,21 +85,23 @@ @dockerfile_config[option] = value if @dockerfile_config.include? option end scan_rails_app + Bundler.with_original_env { install_gems } + template 'Dockerfile.erb', 'Dockerfile' template 'dockerignore.erb', '.dockerignore' 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' if options.compose - template 'dockerfile.yml.erb', 'config/dockerfile.yml' + template 'dockerfile.yml.erb', 'config/dockerfile.yml', force: true end private def render(options) @@ -154,23 +156,37 @@ def keeps? return @keeps if @keeps != nil @keeps = !Dir['**/.keep'] end + def install_gems + if options.postgresql? or @postgresql + system "bundle add pg" unless @gemfile.include? 'pg' + end + + if options.mysql? or @mysql + system "bundle add mysql2" unless @gemfile.include? 'mysql2' + end + + if options.redis? or using_redis? + system "bundle add redis" unless @gemfile.include? 'redis' + end + end + def build_packages # start with the essentials packages = %w(build-essential) # 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 + 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 using_redis? + packages << "redis" if options.redis? or using_redis? # ActiveStorage preview support packages << "libvips" if @gemfile.include? 'ruby-vips' # Rmagick gem