Class: Trek::Generators::Install::ScalingoGenerator

Inherits:
Rails::Generators::Base
  • Object
show all
Includes:
Helpers
Defined in:
lib/generators/trek/install/scalingo_generator.rb

Constant Summary collapse

BUILDPACK_URL =
"https://github.com/etaminstudio/trek-buildpack#v0.1.0".freeze

Instance Method Summary collapse

Instance Method Details

#create_aptfileObject



20
21
22
23
24
25
26
27
28
# File 'lib/generators/trek/install/scalingo_generator.rb', line 20

def create_aptfile
  create_file "Aptfile" do
    <<~TEXT
      libjemalloc2
      libvips-tools --no-install-recommends
      libwebp-dev
    TEXT
  end
end

#create_procfileObject



30
31
32
33
34
35
36
37
38
# File 'lib/generators/trek/install/scalingo_generator.rb', line 30

def create_procfile
  create_file "Procfile" do
    <<~TEXT
      web: bundle exec rails server -p $PORT -e $RAILS_ENV -b 0.0.0.0
      # worker: bundle exec sidekiq -C config/sidekiq.yml
      postdeploy: bundle exec rails db:migrate
    TEXT
  end
end

#final_instructionsObject



40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/generators/trek/install/scalingo_generator.rb', line 40

def final_instructions
  say ""
  say "Configure the Scalingo app environment:"
  say ""
  say "    scalingo --app <app> env-set BUILDPACK_URL=#{BUILDPACK_URL}"
  say "    scalingo --app <app> env-set 'DATABASE_URL=$SCALINGO_POSTGRESQL_URL'"
  say ""
  say "and make sure config/database.yml reads DATABASE_URL in production."
  say ""
  say "See https://trek.etamin.studio/deploy for details."
  say ""
end

#remove_buildpacksObject

The trek-buildpack replaces the apt + ruby buildpack combination. It pins Node from the .node-version that rails new already generates.



16
17
18
# File 'lib/generators/trek/install/scalingo_generator.rb', line 16

def remove_buildpacks
  remove_file ".buildpacks"
end