Skip to content
This repository has been archived by the owner on Apr 19, 2018. It is now read-only.

How to specify base path for a buildpack? #33

Closed
cirovladimir opened this issue Jul 28, 2014 · 3 comments
Closed

How to specify base path for a buildpack? #33

cirovladimir opened this issue Jul 28, 2014 · 3 comments

Comments

@cirovladimir
Copy link

I have a Java application which contains a "Node" (a yeoman generated web app actually) in 'src/main/webapp' dir. When pushed, heroku detects it only as a Java app and runs the corresponding buildpack. I'm trying to use this heroku-buildpack-multi but I can't find a way to specify the base directory for the web app.
Adding the buildpack as it is, fails with the error

Push rejected, failed to compile Multipack app

it expects a package.json file, for the Node buildpack, in root not in src/main/webbapp hence it fails.
My .buildpacks file is

https://github.com/heroku/heroku-buildpack-java.git
https://github.com/heroku/heroku-buildpack-nodejs.git
@cesarandreu
Copy link

I had a similar problem. I have a Rails app, but the frontend is a static app that needs to get built with node.

I forked the nodejs buildpack (you can find my fork here) and did some small tweaks. It's being used in production.

In the root of my project I have a .heroku_config file that contains the following:

export NODE_WORKING_DIRECTORY='/app'
export NODE_BUILD_COMMAND='npm run build'

Here's what my changes do:

  1. Source .heroku_config from the project root (source)
  2. Append the value from NODE_WORKING_DIRECTORY at the end of the first argument that gets passed to the compile script, this means it'll use that as the build directory instead of the normal folder (source
  3. Execute the NODE_BUILD_COMMAND command to build the app or do whatever (if it's a long running process you'll want to add that manually to your Procfile) (source)

I'm not 100% certain, but think that if you set the NODE_WORKING_DIRECTORY and NODE_BUILD_COMMAND environment variables it'll use those, and you won't have to add a .heroku_config file.

Hopefully it works out. Good luck! Please let me know if you end up using my buildpack 😄.

@cirovladimir
Copy link
Author

Thanks for your response, I ended up creating my own version, it allows you to specify the basepath for each buildpack, i.e.

$ cat .buildpacks
https://github.com/heroku/heroku-buildpack-java.git
https://github.com/heroku/heroku-buildpack-nodejs.git   src/main/webapp

@ddollar ddollar closed this as completed Nov 7, 2014
@mewdriller
Copy link

@ddollar: Any chance this basepath feature might make it into your repository? It looks like @cirovladimir's version is starting to diverge a bit...

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

No branches or pull requests

4 participants