17

I have a compiled folder named /target where my server.js lives. Since it's compiled files, I added /target to .gitignore since I don't want all those changes checked it into my GitHub.

But Heroku ignores anything listed in the .gitignore, so I'm unable to spin up the app.

Ideally I'd like to run node /target/scripts/server.js in Heroku. And not have the compiled /target folder checked into GitHub.

What's the best way to handle this situation?

hzhu
  • 3,759
  • 5
  • 29
  • 39
  • Maybe have a separate branch where `/target` is checked in, and push it only to heroku? – Ismail Badawi Mar 09 '15 at 04:19
  • 2
    Generally you should let Heroku generate the built files itself. How are you generating the files in `target/`? – ChrisGPT was on strike Mar 09 '15 at 12:23
  • 1
    `/target` is generated by `./lein cljsbuild auto dev`. Since the compilation takes longer than 60 seconds, Heroku stops the deploy process: `heroku[web.1]: Error R14 (Memory quota exceeded)` `heroku[web.1]: Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch` – hzhu Mar 09 '15 at 16:21
  • `/target` is small. All the compiled files are about 8MB total. – hzhu Mar 09 '15 at 16:22
  • When are you running `./lein cljsbuild auto dev`? – mipadi Mar 09 '15 at 21:06
  • @mipadi currently before I deploy to Heroku. If I run that on Heroku, I get the 60 seconds limit. – hzhu Mar 09 '15 at 22:22
  • @HenryZhu i hope you somewhat resolved the issue, anyway added my answer for someone that come across this question ! – Renjith Thankachan Feb 05 '17 at 10:14

1 Answers1

6

Seems like none answered this question, hope this will help someone :)

Step 1: create a seperate branch for heroku that contains your target folder, say myheroku.

git checkout -b myheroku

Step 2: modify .gitignore by removing target/, run your command lein cljsbuild to generate production files.

git add target/  
git commit -m "your commit message"

Step3: push the branch with target changes to heroku

git push heroku myheroku:master

So, after working & finished testing,

  • checkout your heroku local branch; can generate build files
  • commit & push from localbranch to heroku master as Step3

NOTE: i hope there is no problem for you dealing with that extra commit messages polluting heroku localbranch.

Renjith Thankachan
  • 4,178
  • 1
  • 30
  • 47
  • Actually, it might be better to append to `.gitignore` using negation pattern, rather than directly editing it. – Polv Feb 03 '20 at 10:32