jakeg / heroku-buildpack-bun

Heroku buildpack for Bun.js
MIT License
19 stars 20 forks source link

Explanation/demo of how to use this repo #1

Closed alexandermorgan closed 10 months ago

alexandermorgan commented 10 months ago

This repo looks awesome but I don't understand how to use it. Is there an explanation of how to use it to build a project on Heroku? Maybe it's obvious but I don't know what I'm supposed to do with this repo to get Heroku to use bun instead of npm. The README could have a lot more introductory information.

jakeg commented 10 months ago

In your project on Heroku, go to settings then buildpacks, and add the GitHub URL. See below example, where Bun and Deno buildpacks have been added (you only need the Bun one).

Screenshot_20231029-110746~2

alexandermorgan commented 10 months ago

Thanks! Should I also remove the heroku/nodejs one?

image
jakeg commented 10 months ago

Yes, you can do. Let me know how you get on.

alexandermorgan commented 10 months ago

I couldn't get this to work. The build would work but then the app would crash right away so I couldn't use it. It may have been that I didn't have a Procfile so I added a simple one that was just web: bun start but that didn't work either. There are probably tons of other things I could try but I'm not familiar enough with this. The fact that successfully builds but then immediately fails means that the builds get accepted instead of automatically rejected so I effectively have to take my website offline to debug the setup.

jakeg commented 10 months ago

Have you looked at your logs? Or tried a simple hello world script? My Procfile is just web: bun index.js.

jakeg commented 10 months ago

I've updated the home page readme to hopefully give better usage info

alexandermorgan commented 10 months ago

Thanks for the clarified directions. I was surprised that Heroku accepts the build even with an error coming before it. It looks like there's an issue with bson, but bson isn't a named dependency in my package. It is used by some of my dependencies, but I would have thought that would get sorted out automatically. For reference, here's the relevant part of the logs:

2+00:00 heroku[web.1]: State changed from up to starting 2023-11-08T10:07:54.943531+00:00 heroku[web.1]: Stopping all processes with SIGTERM 2023-11-08T10:07:55.639647+00:00 heroku[web.1]: Starting process with commandbun index.js 2023-11-08T10:07:55.848476+00:00 heroku[web.1]: Process exited with status 0 2023-11-08T10:07:56.692168+00:00 app[web.1]: 2023-11-08T10:07:56.692197+00:00 app[web.1]: 2023-11-08T10:07:56.692203+00:00 app[web.1]: error: FileNotFound while resolving package "bson" from "/app/.bun/install/cache/mongodb@6.2.0/lib/bson.js" 2023-11-08T10:07:56.775173+00:00 heroku[web.1]: Process exited with status 1 2023-11-08T10:07:56.799842+00:00 heroku[web.1]: State changed from starting to crashed

tguelcan commented 3 months ago

I had a similar problem and got an error after the successful build because I had written Procfile in lower case.