Giter VIP home page Giter VIP logo

heroku-buildpack-bun's People

Contributors

jakeg avatar noxan avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

heroku-buildpack-bun's Issues

Possibility to opt-out of steps

Thanks for this great buildpack!

We used your buildpack to simply install bun, install dependencies with bun and then use the node buildpack to run the remaining actions. This is needed, because we're in the middle of a migration phase and not everything is bun compatible yet - and it yet won't be for quite some time I think.

Unfortunately, after your recent changes, we need to use an older version of your buildpack because the latest one is breaking our heroku build process. Get me right, the changes you did were great, but they simply doesn't work (yet) for us!

Would there be any chance that we could add possibility to opt-out of some steps?
Maybe via a config file?

Let me know what you think.

Specify bun version with `.bun-version` file (without `v` prefix)

What about adding support for specifying the bun version from yet another, maybe custom file?
I also think it's a good idea to make the version prefix v optional.

Take this as an example https://github.com/oven-sh/setup-bun?tab=readme-ov-file#inputs where one can read the content out of the .bun-version file to specify the bun version for the GitHub action.

Currently, we have two files in our repository runtime.bun.txt and .bun-version with the same information (except the v). And it would be really cool, if we can rely on just one single file, in our case .bun-version.

What do you think?

Env problem during pre-build step

Hey! Are env variables not available during the heroku-prebuild step?

Even though they are there after the app goes live (i can see tem with printenv), when running the prebuild im getting a validation error cause they arent there.

This is my env configuration file with zod:

import { config } from 'dotenv'
import { expand } from 'dotenv-expand'

import { ZodError, z } from 'zod'

const stringBoolean = z.coerce
  .string()
  .transform((val) => {
    return val === 'true'
  })
  .default('false')

const EnvSchema = z.object({
  NODE_ENV: z.string().default('development'),
  DATABASE_URL: z.string(),
  DB_MIGRATING: stringBoolean,
  DB_SEEDING: stringBoolean,
  APP_SECRET: z.string(),
})

export type EnvSchema = z.infer<typeof EnvSchema>

expand(config())

try {
  EnvSchema.parse(process.env)
} catch (error) {
  if (error instanceof ZodError) {
    let message = 'Missing required values in .env:\n'
    error.issues.forEach((issue) => {
      message += issue.path[0] + '\n'
    })

    const e = new Error(message)
    console.log(process.env)

    e.stack = ''
    throw e
  } else {
    console.log(error)
  }
}

export default EnvSchema.parse(process.env)

Very straight forward and works fine when the start script runs. Just the build that fails, I cant migrate and seed my db because of it. Here is my package.json with the commands:

{
  "name": "hono-backend",
  "scripts": {
    "dev": "bun run --watch src/index.ts",
    "db:generate": "drizzle-kit generate",
    "db:migrate": "cross-env DB_MIGRATING=true bun run src/db/migrate.ts",
    "db:seed": "cross-env DB_SEEDING=true bun run src/db/seed.ts",
    "db:studio": "drizzle-kit studio",
    "route:test": "bun db:seed && bun test",
    "heroku-prebuild": "bun db:migrate && bun db:seed",
    "build": "bun --target bun build ./src/index.ts --outdir ./build",
    "start": "bun build/index.js"
  },
  "dependencies": {
    "@hono/zod-validator": "^0.2.2",
    "dotenv": "^16.4.5",
    "dotenv-expand": "^11.0.6",
    "drizzle-orm": "^0.31.2",
    "drizzle-zod": "^0.5.1",
    "hono": "^4.4.8",
    "postgres": "^3.4.4",
    "reflect-metadata": "^0.2.2",
    "typedi": "^0.10.0",
    "zod": "^3.23.8"
  },
  "devDependencies": {
    "@eslint/js": "^9.5.0",
    "@types/bun": "latest",
    "cross-env": "^7.0.3",
    "drizzle-kit": "^0.22.7",
    "eslint": "9.x",
    "eslint-config-prettier": "^9.1.0",
    "globals": "^15.6.0",
    "prettier": "^3.3.2",
    "typescript-eslint": "^7.14.1"
  }
}

The error I get is that DATABASE_URL and APP_SECRET are missing during the prebuild step. But they are in the console and show up with printenv once the app starts

Explanation/demo of how to use this repo

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.

Rails app still can't deploy during assets:precompile

Tried to upgrade to cssbundling-rails 1.3.3 or 1.4.0 which support bun, and deploy to heroku with this buildpack

(Same deal with jsbundling-rails 1.1.2 -> 1.2.2, 1.3.0 due to similar bun support added)

-----> https://github.com/jakeg/heroku-buildpack-bun app detected
#=#=#                                                                         bun was installed successfully to /tmp/build_b164eac6/.heroku/bin/bun 
Manually add the directory to ~/.bash_profile (or similar):
  export BUN_INSTALL="/tmp/build_b164eac6/.heroku" 
  export PATH=$BUN_INSTALL/bin:$PATH 
To get started, run: 
  bun --help 
Installing dependencies...
[0.04ms] ".env.production"
bun install v1.1.12 (43f0913c)
+ [email protected]
...
+ [email protected]
579 packages installed [2.21s]
Blocked 1 postinstall. Run `bun pm untrusted` for details.
-----> Ruby app detected
-----> Installing bundler 2.5.6`
...
-----> Installing node-v20.9.0-linux-x64
-----> Installing yarn-v1.22.19
-----> Detecting rake tasks
-----> Preparing app for Rails asset pipeline
       Running: rake assets:precompile
       I, [2024-06-05T14:06:00.286037 #3047]  INFO -- ddtrace: [ddtrace] DATADOG CONFIGURATION - CORE - {"date":"2024-06-05T14:06:00Z","os_name":"x86_64-pc-linux","version":"1.23.0","lang":"ruby","lang_version":"3.3.2","env":"staging","service":"rake","dd_version":null,"debug":false,"tags":"env:staging","runtime_metrics_enabled":false,"vm":"ruby-3.3.2","health_metrics_enabled":false,"profiling_enabled":false}
       [dotenv] Loaded .env.production
       [dotenv] Loaded .env.staging
       [dotenv] Loaded .env.production
       rake aborted!
       cssbundling-rails: Command install failed, ensure bun is installed
       /tmp/build_b164eac6/vendor/bundle/ruby/3.3.0/gems/cssbundling-rails-1.4.0/lib/tasks/cssbundling/build.rake:6:in `block (2 levels) in <main>'
       /tmp/build_b164eac6/vendor/bundle/ruby/3.3.0/gems/ddtrace-1.23.0/lib/datadog/tracing/contrib/rake/instrumentation.rb:30:in `execute'
       Tasks: TOP => assets:precompile => css:build => css:install

The failing line in cssbundling-rails https://github.com/rails/cssbundling-rails/blob/e650c9ab135504cc2f8b8405c41cdebad5ede66f/lib/tasks/cssbundling/build.rake#L26

I downgraded back to 1.2.0 and removed the buildpack, and my deploys are building again.

Here is our buildpack list now (after removing bun; it had been listed before node's)

Screenshot 2024-06-05 at 08-17-50 · Settings Heroku

Dependencies are missing

Looks like dependencies are not installing by default on deployment. I'm getting following error:

$ bun run ./src/index.ts
2024-01-22T16:40:43.782307+00:00 app[web.1]: error: FileNotFound while resolving package "typeorm" from "/app/src/database/dataSource.ts"
2024-01-22T16:40:43.789967+00:00 app[web.1]: error: script "start" exited with code 1

Although typeorm is in the dependencies in package.json file.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.