Automate tasks for Deploying Ember-CLI-Rails app on AWS
michaelcheatham0182 opened this issue · 0 comments
MacOS High Sierra 10.13.4 (17E202)
Ruby 2.5.0 Rails 5.1.5
npm 6.1.0
ember-cli 3.0.0
ember cli rails 0.10.0
node 9.10.1
"ember-cli-rails-addon": "^0.10.0"
Application server is multi-threaded => puma
config/initializers/ember.rb
:
EmberCli.configure do |c|
c.app :frontend
end
Rails view that renders Ember Application:
<!DOCTYPE html>
<html>
<head>
<title>Gamma Fit</title>
<%= csrf_meta_tags %>
<%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track': 'reload' %>
<%= javascript_include_tag 'application', 'data-turbolinks-track': 'reload' %>
<link rel="manifest" href="/manifest.json" />
<meta name="apple-mobile-web-app-capable" content="yes"></head>
<body>
<%= yield %>
</body>
</html>
EmberCLI-related routes:
mount_ember_app :frontend, to: "/"
I am using Capistrano for deployment on nginx web server and AWS instance. I am following these 2 sources:
https://www.youtube.com/watch?v=imdrYD4ooIk&t=150s
I follow the instructions and everything works fine. The problem is vendor.css, vendor.js, frontend.css, frontend.js are not copied to app/public/assets folder.
However, I am able to run the build successfully by manually copying these files to the desired assets folder. I did this by going through deployment logs which read:
01 - /home/deploy/{app-name}/releases/20180701213801/tmp/ember-cli/apps/frontend/assets/frontend-7b19d05f0c30463b6bc445254c46260a.js: 167.85 KB (19.56 KB gzipped)
01 - /home/deploy/{app-name}/releases/20180701213801/tmp/ember-cli/apps/frontend/assets/frontend-a6e35fc1f15073bdd000b39efd15f59a.css: 148.16 KB (24 KB gzipped)
01 - /home/deploy/{app-name}/releases/20180701213801/tmp/ember-cli/apps/frontend/assets/vendor-711976a824e2656ad208cb4c16c1dfc4.js: 1.16 MB (274.52 KB gzipped)
01 - /home/deploy/{app-name}/releases/20180701213801/tmp/ember-cli/apps/frontend/assets/vendor-d3aa84b783735f00b7be359e81298bf2.css: 38 B (58 B gzipped)
I copied these files to app/public/assets
folder explicitly for everything to work fine.
Also, I face 502 error whenever I first deploy the app. For that, I always kill puma process using sudo kill -9 {pid} and then restarting puma server using bundle exec puma -e production -d -b Unix:/home/deploy/{app-name}/shared/tmp/sockets/puma.sock
And then, I restart nginx server.
Following these steps, I am able to deploy everything successfully.
But this is a lot of work. I rather aim to automate everything. I don't want to copy files explicitly and I don't want to restart the puma and nginx server every time. How do I achieve this?
Also, I need to add 'bower': '*'
in the package.json
file every time before deployment. Any way to automate this?
Last thing: I want to run some rake tasks from local. Currently, I use this command: bundle exec rake {my_rake_task} RAILS_ENV=production DISABLE_DATABASE_ENVIRONMENT_CHECK=1
on the server machine. Any suggestions?