CommanderB CommanderB - 1 year ago 45
Java Question

Deploying java backend and Javascript frontend

I have an app that I would like to deploy to Heruko. The

API is built with
and the frontend is built with
. Is there a way to deploy the two together in the same file structure?

Answer Source

You can use Heroku's support for running multiple buildpacks on an app. In short, you can run this:

$ heroku buildpacks:clear 
$ heroku buildpacks:add heroku/nodejs
$ heroku buildpacks:add heroku/java

If your app has a package.json and a pom.xml this should pretty much just work. The only caveat you might run into is the dependencies versus devDependencies in the package.json. The Node.js buildpack will not install devDependencies by default, so you may need to run:

$ heroku config:set NPM_CONFIG_PRODUCTION=false

Here is an article that describes this setup for Using Grunt with Java and Maven to Automate JavaScript Tasks, but it's basically the same for Gulp.

I don't understand your question about the symlinks.


Maybe the symlinks question implies that the code for the frontend and backend are not in the same repo? I recommend merging these, or using Git submodules. Or you can package the whole app (frontend assets and backend code) into an executable JAR file and deploy with heroku-cli-deploy.