This repository has been archived by the owner. It is now read-only.

How to specify base path for a buildpack? #33

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

Comments

Projects
None yet
4 participants
@cirovladimir

cirovladimir commented Jul 28, 2014

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

This comment has been minimized.

Show comment
Hide comment
@cesarandreu

cesarandreu Jul 31, 2014

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 😄.

cesarandreu commented Jul 31, 2014

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

This comment has been minimized.

Show comment
Hide comment
@cirovladimir

cirovladimir Aug 7, 2014

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

cirovladimir commented Aug 7, 2014

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 Nov 7, 2014

@mewdriller

This comment has been minimized.

Show comment
Hide comment
@mewdriller

mewdriller May 26, 2015

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

mewdriller commented May 26, 2015

@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.