We have a rails site that is expanding quite a bit. it is using jruby, bootstrap, and some third party libraries - and the precompile takes a long time. too long for the timeout limits on heroku for deployment. is there a way to modify the timeout values so we'll be able to push our repository to heroku and have it precompile?
thanks.
pre-compile locally and switch off heroku pre-compile?
Related
I'm currently developing a simple webapp with seperated frontend (Vue) and backend (quarkus REST API) project. For now, I've setup a MVP, where the frontend is displaying some simple data which is called from the backend. To get a working MVP i need to setup CORS support. However, first i want to explain my setup:
Setup
I'm starting developing environment of my frontend with npm run serve and of my backend with ./mvnw quarkus:dev. Frontend is running on localhost:8081 and backend running on localhost:8080.
Heroku allows to run your apps locally aswell with the command heroku local web. Frontend is running on port 0.0.0.0:5001 and backend on 0.0.0.0:5000.
To achieve this setup i setup two .env files on my frontend which are pointing to my backend api. If i want to work in development mode the file .env.development is loaded:
VUE_APP_ROOT_API=http://localhost:8080
and if i run heroku local web the file .env.local with
VUE_APP_ROOT_API=0.0.0.0:5000
is loaded.
In my backend I've set
quarkus.http.cors=true
in my application.properties.
Now I want to deploy those two projects to heroku and use it in production. Therefore I setup two heroku projects and set a config variable in my frontend project with the following value:
VUE_APP_ROOT_API:https://mybackend.herokuapp.com
Calls from my frontend are successfully working!
Question
For the next step, I want to restrict it more and just enable my frontend to call my API. I know i can set something like
quarkus.http.cors.origins=myfrontend.herokuapp.com
However, I dont know how i could do this on quarkus with different environments (development, local and production)? I've found this link but I don't know how to configure heroku and my backend app correctly. Do i need to setup different profiles which are applied on my different environments? Or is there another solution? Do i need Herokus Config Variables?
Thanks for the help so far!
quarkus.http.cors.origins is overridable at runtime so you have several possibilities.
You could use a profile and have everything set up in your application.properties with %prod.quarkus.http.cors.origins=.... Then you either use -Dquarkus.profile=prod when launching your application or you use QUARKUS_PROFILE=prod as an environment variable.
Another option is to use an environment variable for quarkus.http.cors.origins. That would be QUARKUS_HTTP_CORS_ORIGINS=....
My recommendation would be to use a profile. That way you can safely check that all your configuration is consistent at a glance.
I am really confused on how to get Resque and resque_mailer working on my production server. What I need to do is get a single worker running/restart which is called 'mailer' via Capistrano when I do a cap deploy.
I've seen this gist but I just don't get it. Is there something else that breaks it down to explain what its doing. Or is there a simpler solution to get this working?
I've already got Redis working as I'm already using it for other tasks.
My production server is as follows: Ubuntu, Apache, Passenger, Ruby 2.0, Rails 4.0
In the end I used Sidekiq. The documentation is much better and just works!
N00b question here, but I am currently deploying my Rails webapp on my EC2 server instance using rubber. I was previously deploying on heroku (got frustrated with how slow it was on each startup) and decided to switch hosts last night.
There are a few environment variables I'd like to set upon deploying (for stripe). In my heroku case, I was able to just set the environment variables at the command line using something like:
heroku set ENV_VAR1=xxxxyyyyzzzz ENV_VAR2=xxxxyyyyzzzz
I was wondering if there was either a cap command, or some file I could alter to set those evironment vars on EC2, or even a command from the command line I could run to set them? I am not super familiar with rubber / cap, as I was just following one of the rails cast videos last night.
Thanks everyone.
I am relatively inexperienced in rails and I am confused by where Capistrano fits into the rails app life cycle.
From my understanding the following steps are involved in getting a rails app completed.
Select and set up a host (e.g linode)
Install apache2
Install rvm
Install ruby and install rails
Install passenger
Create an application and test at domain.com:3000 by using 'rails s' command
However it is not clear to me how the next steps work. In particular:
a) The live rails app needs to run in production mode at domain.com, I presume passenger does this?
b) If I have created the app at domain.com:3000 do I need to do anything in the rails config before it works at domain.com?
c) Where does capistrano fit in? If passenger can make my app work at domain.com, what does capistrano do?
a) Exactly, passenger working with a web server like Apache does this for you.
b) Your local web server is not the same with Passenger. To set it up in your domain, you would need to normally create your domain and set a website as you normally set a website in your apache(or other) configuration.
c) Capistrano is a gem that allows you to write scripts which automate things, like restarting the web server, or setting particular production versions and so on.
For more information on Capistrano :
http://railscasts.com/episodes/133-capistrano-tasks
I use my server to store user uploaded pictures. This is great however when I make a change to the code it reflects this and deletes my pictures stored on the server.
git push heroku master
How do I prevent this?
Heroku's filesystem is read-only so you can't and shouldn't store uploaded files in your dynos.
If you think about it, it makes sense. You can have multiple dynos running your app so you can't guarantee which dyno is receiving the pictures.
Dynos should be stateless anyway, so you can easily scale your application up or down.
The preferred way to do file uploads on Heroku is to use Amazon S3 as outlined in their DevCenter.
Like leonardoborges Heroku's filesytem is read-only. Since you are using rails you can use a gem like carrierwave that helps when you are handling images in your app and it is easy to set up with Amazon S3.
Other helpful links
Carrierwave Railscast