Heroku + Github deployment strategies

前端 未结 4 2133
独厮守ぢ
独厮守ぢ 2021-02-13 06:05

I am working on a web app, hosting the source code on Github and running the app on Heroku. Everything works fine, but I have on issue I can\'t wrap my head around. Before the d

4条回答
  •  再見小時候
    2021-02-13 06:39

    This situation is a bit unusual. But here are some ideas:

    • I use a process that's similar to the one in the article you referenced.
    • I'd create only a single app as your saying. I'd create it starting a new git repository in your dev folder.
    • I'd then recommend a deployment strategy similar to the one described in this answer: https://stackoverflow.com/a/8058194/267025 . I've adapted it below:

    Create a rake file with two tasks in it: rake deploy:production and rake deploy:postprocess_files. Those tasks might look something like this:

    namespace :deploy do
    
      task :production do
        puts "turn on 'maintenance page' on heroku"
        system "heroku maintenance:on"
    
        puts "deploying to production"
        system "git push heroku-prod master"
    
        puts "post processing files..."
        system "heroku run rake production:postprocess_files"
    
        puts "take off maintenance page"
        system "heroku maintenance:off"
    
        puts "done"
      end 
    
      task :postprocess_files do
        puts "run postprocessing of files on heroku"
        ... add commands here to post process the files.
      end 
    end
    

    Then deploy to production using rake deploy:production rather than pushing using git directly. The rake file will then:

    1. set the maintenance page,
    2. push to production,
    3. do your post processing of files,
    4. take down the maintenance page.

    Note that the second rake task in your file has the commands to do the post processing on your files and is invoked to run on heroku by the first rake task.

    As an alternative, it's possible you may be able to extend the assets:precompile task that Heroku runs as part of each deploy. That's essentially what you're doing anyway -- preparing assets for deployment to production.

提交回复
热议问题