Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

attempting Heroku deployment #358

Merged
merged 21 commits into from
Dec 4, 2015
Merged

attempting Heroku deployment #358

merged 21 commits into from
Dec 4, 2015

Conversation

MatthewVita
Copy link
Contributor

@whit537 starting out here.

Going to set up a fresh heroku box and try these rake tasks. I'm not sure if doing the steps through rake tasks is the most elegant approach, tbh.

@MatthewVita
Copy link
Contributor Author

$ heroku login
$ heroku create
$ heroku config:set RAILS_SERVE_STATIC_FILES=enabled
$ heroku config:set RAILS_ENV=production
$ heroku config:set RAILS_ENV=production
$ heroku config:set APP_TOKEN=foo123abc
$ heroku config:set APP_SECRET=bar789xyz
$ heroku config:set APP_DATABASE_USER=somebody
$ heroku config:set APP_DATABASE_PASS=somepass
$ git push heroku heroku-matthew:master
$ heroku run rake db:migrate
$ heroku run rake db:seed
$ heroku run rake npm
$ heroku run rake gulp

...note that everything is good until the rake npm and gulp commands :( I don't know where the app directory is on heroku

@MatthewVita
Copy link
Contributor Author

wait...

matthew@matthew-VirtualBox ~/code/cityasacampus $ heroku run bash
Running bash on arcane-island-8296... up, run.2489
~ $ ls
app   config     dev           GETTING_STARTED.md  Rakefile   vendor
app.json  config.ru  examples      lib         README.md
bin   datamodel.pdf  Gemfile       log         test
client    db         Gemfile.lock  public          tmp
~ $ pwd
/app
~ $ 

w00t! need to amend this branch

@MatthewVita
Copy link
Contributor Author

@MatthewVita
Copy link
Contributor Author

https://arcane-island-8296.herokuapp.com/ has no static assets to serve up atm, of course

@chadwhitacre
Copy link
Contributor

@MatthewVita The db:migrate and db:seed tasks are one-time, right? How about npm and gulp? Do those need to be run once, or every time we deploy?

@chadwhitacre
Copy link
Contributor

Heroku is designed for dynamic resources, not static ones. We should consider using a CDN for our static assets. Here's Heroku's docs on integrating with Amazon CloudFront. Over on Gratipay, we're using MaxCDN successfully for static assets.

@chadwhitacre
Copy link
Contributor

What's our current static setup? How do npm/gulp interact with the Rails asset pipeline, if at all?

@MatthewVita
Copy link
Contributor Author

@whit537 I should be clear: gulp just "compiles" our frontend to the Rails "public" directory

@MatthewVita
Copy link
Contributor Author

db:migrate, npm, and gulp should be run every push, yes

@chadwhitacre
Copy link
Contributor

Okay, and the npm install is so we can use gulp, right?

@MatthewVita
Copy link
Contributor Author

yes, and so we can have frontend dependencies resolved (such as angular, jquery, etc)

@chadwhitacre
Copy link
Contributor

Resolved when/where? Per-request on the server side or something?

@MatthewVita
Copy link
Contributor Author

npm downloads the dependencies and gulp shoves them into the vendors.min.js and vendors.min.css files

@chadwhitacre
Copy link
Contributor

Looks like you're on the right track with heroku run rake db:migrate:

https://devcenter.heroku.com/articles/getting-started-with-rails4#migrate-your-database

@chadwhitacre
Copy link
Contributor

npm downloads the dependencies and gulp shoves them into the vendors.min.js and vendors.min.css files

Okay, so still only happening once per deploy.

@chadwhitacre
Copy link
Contributor

Regardless of the webserver you choose, production apps should always specify the webserver explicitly in the Procfile.

https://devcenter.heroku.com/articles/getting-started-with-rails4#webserver

@MatthewVita
Copy link
Contributor Author

cool. Do you mind looking into that? I'm currently fighting with getting rake task to run correctly (almost there...)

@MatthewVita
Copy link
Contributor Author

btw, WebBrick is currently what's being used, which is not good

@MatthewVita
Copy link
Contributor Author

damnit. Heroku has node installed by default but not npm...

@chadwhitacre
Copy link
Contributor

Do you mind looking into that?

Sure thing! :-)

@MatthewVita
Copy link
Contributor Author

heroku buildpacks:set https://github.com/heroku/heroku-buildpack-nodejs#v83

hmmmm

@MatthewVita
Copy link
Contributor Author

remote:  !     Push rejected, failed to detect set buildpack https://github.com/heroku/heroku-buildpack-nodejs#v83
remote: More info: https://devcenter.heroku.com/articles/buildpacks#detection-failure
https://github.com/heroku/heroku-buildpack-nodejs#v83
Unsetting https://github.com/heroku/heroku-buildpack-nodejs#v83 and restarting arcane-island-8296... done

nope :(

@chadwhitacre
Copy link
Contributor

@chadwhitacre
Copy link
Contributor

@MatthewVita
Copy link
Contributor Author

/me trying to figure out how to install npm with buildpacks and failing miserably lol

@chadwhitacre
Copy link
Contributor

@MatthewVita Not sure how you're approaching it, but you should only have one buildpack per application. Either we use Heroku's official Rails buildpack, or their official Node.js one, or we roll our own that combines the two. Seems like we should be able to find a way to install npm without rolling our own buildpack.

@chadwhitacre
Copy link
Contributor

@dmtroyer Reticketed as #359! :-)

@chadwhitacre
Copy link
Contributor

Alright @dmtroyer @MatthewVita, ready for review! :-)

@chadwhitacre
Copy link
Contributor

I'm reviewing local dev deployment ...

@chadwhitacre chadwhitacre mentioned this pull request Nov 30, 2015
@chadwhitacre
Copy link
Contributor

I think there are some other changes we should make to local dev deployment, but they're out of scope for this PR. Reticketed as #360.

@chadwhitacre
Copy link
Contributor

This PR breaks the scripts in dev. I'm going to fix those here to remove a reason not to merge this :-), though I think we should change them (#360).

@chadwhitacre
Copy link
Contributor

Hmm ... I ran dev/src/install.sh against a clean DigitalOcean droplet, and it appears to have completed successfully, though I can't access the app server externally, I believe because it's bound to localhost.

@chadwhitacre
Copy link
Contributor

[I]t appears to have completed successfully, though I can't access the app server externally, I believe because it's bound to localhost.

I think I'm gonna consider that good enough for this PR. S'okay, @MatthewVita?

@MatthewVita
Copy link
Contributor Author

@whit537 thanks for your patience and great work.

Hmm ... I ran dev/src/install.sh against a clean DigitalOcean droplet, and it appears to have completed successfully, though I can't access the app server externally, I believe because it's bound to localhost.

Just tried it on a fresh EC2 instance and the following worked:

ubuntu@ip-172-31-34-97:~/cityasacampus/dev/src$ rails s & sleep 3 && wget localhost:3000 && cat index.html #spits out HTML

ubuntu@ip-172-31-34-97:~/cityasacampus/dev/src$ rails s & sleep 3 && wget localhost:3000/topics.json && cat topics.json #spits out JSON from GET endpoint

I'm going to merge now. My only comment was on how you did the comments in package.json... according to http://stackoverflow.com/a/14221781 we should be able to use the key "//" to comment in package.json, but it didn't work :(.

I also ripped out the old rake tasks here: hhttps://github.com/saxifrage/cityasacampus/commit/485a2996588d5329a4acb770b9dab0eaae6d6b37

MatthewVita added a commit that referenced this pull request Dec 4, 2015
@MatthewVita MatthewVita merged commit 72eaf1e into master Dec 4, 2015
@MatthewVita MatthewVita deleted the heroku-matthew branch December 4, 2015 03:20
@chadwhitacre
Copy link
Contributor

My only comment was on how you did the comments in package.json... according to http://stackoverflow.com/a/14221781 we should be able to use the key "//" to comment in package.json, but it didn't work :(.

Right. See http://stackoverflow.com/questions/14221579/how-do-i-add-comments-to-package-json-for-npm-install/14221781#comment50530934_14221781.

I also ripped out the old rake tasks

wfm

I'm going to merge now.

Woo-hoo! Thank you! :-D

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants