I'm in the process of deploying my Rails app (it also uses redux, react, as well as some Ruby and Javascript). And I'm on the step in the official Heroku guide where it specifies to add a Procfile.
I assume that these are the commands that will run once the apps starts up; what exactly do I need to put in here for a Rails app that uses a database?
Locally, I know that to start my app I run rails s, as well as setting up the database beforehand; do I need to do something like that in the Procfile?
Related
Right now, I am running a Vue app within a phoenix app. I first created a phoenix project and then started a Vue app with the name of assets.. for running it in the development environment. I have added
watchers: [npm: ["run", "build", cd: Path.expand("../assets", __DIR__)]]
which each time creates a build which is being used in app.html.eex from priv/static..
and For deployment, I am using phoenix static build pack.. which in production before deploy creates a build before ahead and then run phoenix app. everything is working fine. but its wrong way due to which..
overall benefits of Vue application is not being availed. e.g code splitting/loading code chunk on-page request only. and many other webpack features which we can avail within a Vue app are all not being availed as we just creating the build and putting it in production.
My issue is that. I have seen in may tutorials that run a Vue app with your API as a proxy. and so that the main app will be Vue and Phoenix API will work behind a proxy.
Right now I have this setup to deploy and work in development mode. My question is how I can achieve the opposite to that?
Starting Vue application which will automatically start the phoenix app as well. Also for deploying on Heroku. API will run simply but Vue app will for more functional than just a JS or CSS file static files?
Update: Is it possible to make an umbrella application in which one is Vue and one is phoenix?
This is more of an extended comment, but it was getting really big so I moved it to an answer.
To start two or more apps you will need something like foreman (in heroku, I think there's a buildpack with it) or systemd, or even start a nodejs server from your elixir app (not sure this is doable in heroku).
You can also split manually your components through the webpack config used by phoenix, this can be a bit more involved than just serving a single js file. The reason to split it into two separate services needs to be thought of, but this is usually achieved (if I'm not mistaken, it's been a while since I used it in this way) with having different entry points. For webpack to work the best with splitting assets (css&others) you'll need to also write your vue components in a way that webpack can then understand the dependencies (at least this was the case - and there might be some complexities with the webpack chunking and phoenix digest when using dynamic components, etc).
Other option is to, for instance, use an independent nuxt app, which bundles up a VueJS app with everything you need, webpack, server, vuex, a sensible config and "structure" etc. Now you have two distinct applications, running each an http server, you use asyncData & fetch to populate/hidrate your front-end with data from the phoenix app, you can use async components and all that stuff. Then you deploy the front-end (nuxt app) to one heroku instance and the phoenix server on other instance or somewhere else.
At that point your phoenix app is basically an api for the front-end. So the vue app has to be built with that in mind, and now you've got 2 applications to deploy&take care of. It does help in a lot of fronts but it's also more complexity (authorization, cookies, etc), hence why it needs to be weighted if it's worth doing it. The major benefit is that since they're now 2 apps, styling and things related to the front-end can be deployed without needing to re-deploy the back-end.
Depending on the type of front-end you can also deploy the nuxt app as a static website to something like s3/cloudfront or any other cloud storage engine. For instance if you have like, X public pages that are all mostly static content and everything that is dynamic data is behind a login wall or something, then that is a solution that works fine too.
All 3 ways are valid depending on what you need/reason to do it.
I am making a API project on OpenShift, which has a Node.js server and Ruby backend. I have set up a deployment for Node.js to handle API requests and a MongoDB deployment to store the data, but I'm having trouble with the Ruby backend.
The Ruby backend is responsible for updating the database every so often and thus must run at a regular interval or constantly. That's find, the issue is that OpenShift seems to want me to use Rack to start a web server, but that's not what I want. I just want the Ruby to run as a daemon and scrape the web to update the API every, say, 15 minutes.
How can I use Ruby without making a webserver- that is, get around the errors about not having Rack gem installed?
I am using Revel for developing a Go application, I was wondering how can I run a function just before App Loads or something like that. I know Revel provides revel.OnAppStart but it runs only when we hit any URL. What I want is to call the function as soon as I run the command revel run myApp without any extra things to do.
I got the answer from community support...revel.OnAppStart runs as expected...but only when the environment is PROD not on DEV...because in testing the app is only started by the proxy when there's a request.
Is it possible to configure multiple web-server to an app-server in heroku? Playing with heroku, I don't see that is possible. Heroku deployment as I understand doesn't support web and app server separation. Just wanted to double check my understanding.
Appreciate your thoughts on this!
Heroku as things stand today, does not have a web-server option. You got to keep this in mind for some of your app configurations like cacheing, response compressing etc.
In the case of rails or node platforms, you got to set app-level configurations or have middlewares to take care of these kind of things.
I have been learning Ruby and Sinatra over the past couple months and I would like to get my app out in the wild. I am looking for suggestions for web hosts that support Sinatra apps and any details as to the actual process would be great as well.
I currently use hostmonster for a couple other sites. Hostmonster does support Rails applications. I would assume since Rails runs on Rack, hostmonster will also run Sinatra apps but I am not certain.
I haven't had much luck finding documentation on running Sinatra apps on hostmonster or any other web host outside of Heroku. Also, I haven't been able to figure out how to get my Sinatra app running by following through the Rails installation documentation provided by hostmonster.
You should be able to run on any app that works for Rack. The convention is to use the config.ru file. In there, instead of specifying how to load Rails, just specify how to load Sinatra.
Example config.ru
require File.dirname(__FILE__) + "/main"
run Sinatra::Application
Where "main" is the file that loads all the Sinatra stuff.