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

Prod heroku #2

Merged
merged 5 commits into from
Aug 19, 2017
Merged

Prod heroku #2

merged 5 commits into from
Aug 19, 2017

Conversation

gabrieljoelc
Copy link
Owner

@gabrieljoelc gabrieljoelc commented Aug 19, 2017

This contains a production-specific Docker build. The main web Dyno process works including:

I was unable to get the orats base Dockerfile to work out of the box in Heroku. Here's a summary of what I had to do to get things working in production/Heroku:

  • Manually add some environment variables to Heroku
  • Allow config/puma.rb to assume the IP address for bind but require the PORT env variable which Heroku sets automatically

See the commit messages for more details.

Futures

Ideally, I'd like to get a single Dockerfile that could be used in all environments.

Both commits mention:

  • Other sub-processes/resrouces to still be tested:
    • ActiveMail - SMTP
    • ActiveJob - Redis
    • ActionCable - Redis, CORS
    • Cache - Redis

I am going to merge this PR anyway so I can test pushing features changes to production. I will defer these to #3.

Resources

https://github.com/nickjj/orats

Rails + Docker
https://devcenter.heroku.com/articles/container-registry-and-runtime
https://nickjanetakis.com/blog/dockerize-a-rails-5-postgres-redis-sidekiq-action-cable-app-with-docker-compose
https://dzone.com/articles/deploying-your-docker-rails-app
https://blog.red-badger.com/blog/2016/06/22/docker-and-assets-and-rails-oh-my

Rails + Heroku
https://blog.heroku.com/real_time_rails_implementing_websockets_in_rails_5_with_action_cable
https://devcenter.heroku.com/articles/deploying-rails-applications-with-the-puma-web-server#port
https://blog.heroku.com/container_ready_rails_5

Docker
https://www.digitalocean.com/community/tutorials/how-to-remove-docker-images-containers-and-volumes

This is working for the main web process in Heroku. Here are some
caveats:
- Forced to add a dummy ACTION_CABLE_ALLOWED_REQUEST_ORIGINS env variable to
Dockerfile.web to make the repcompile task run successfully because
config/application.rb assumes it has a value (invokes split)
- Manually added the following variables to Heroku:
  - SECRET_TOKEN=`rails secret` (or heroku config:set
    SECRET_TOKEN=`docker-compose run --rm
    website rails secret`)
  - ACTION_CABLE_ALLOWED_REQUEST_ORIGINS=`heroku apps:info | grep "Web
    URL:" | sed -e 's/^Web URL:        //'`

- Other sub-processes/resrouces to still be tested:
  - ActiveMail - SMTP
  - ActiveJob - Redis
  - ActionCable - Redis, CORS
  - Cache - Redis
This makes it easier to use the PORT env that Heroku sets automatically.

*The main web dyno was running in Heroku at this commit.* However, the
assests were 404ing:
> Failed to load resource: the server responded with a status of 404 (Not
Found)
https://superrandomdomain.herokuapp.com/assets/application-85cc27dda36172aa13df3b2a8ce284c375a233606df823c56c23e15915ba7ba0.css

I fixed by manually setting the environment variable: RAILS_SERVE_STATIC_FILES=true

- Other sub-processes/resrouces to still be tested:
  - ActiveMail - SMTP
  - ActiveJob - Redis
  - ActionCable - Redis, CORS
  - Cache - Redis
@gabrieljoelc gabrieljoelc merged commit 685e76d into master Aug 19, 2017
@gabrieljoelc gabrieljoelc deleted the prod-heroku branch August 19, 2017 19:12
@gabrieljoelc gabrieljoelc added this to Done in MVP Aug 20, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
No open projects
MVP
Done
Development

Successfully merging this pull request may close these issues.

None yet

1 participant