Bun could not find a package.json file to install from
lagametv
FREEOP

10 months ago

I have the following configuration. What's wrong?

{
    "$schema": "https://schema.railpack.com/",
    "secrets": [
        "BETTER_AUTH_SECRET",
        "BETTER_AUTH_URL",
        "CORS_ORIGIN",
        "DATABASE_URL",
        "DISCORD_CLIENT_ID",
        "DISCORD_CLIENT_SECRET",
        "GOOGLE_CLIENT_ID",
        "GOOGLE_CLIENT_SECRET",
        "TWITCH_CLIENT_ID",
        "TWITCH_CLIENT_SECRET"
    ],
    "steps": {
        "install": {
            "commands": ["bun install"],
            "variables": {
                "NODE_ENV": "production"
            }
        },
        "build": {
            "inputs": [{ "step": "install" }],
            "secrets": ["BETTER_AUTH_URL", "CORS_ORIGIN", "DATABASE_URL"],
            "commands": ["bun run db:generate && bun run --filter web build"]
        },
        "predeploy": {
            "inputs": [{ "step": "build" }],
            "commands": ["bun run db:migrate"]
        }
    },
    "deploy": {
        "startCommand": "bun run --filter web start",
        "variables": {
            "NODE_ENV": "production"
        }
    }
}

I somehow got it working using some configs in the Settings tab but I'm wondering if it's possible to make this work only using a railpack config.

Closed$10 Bounty

75 Replies

irazvan2745
FREE

10 months ago

You don’t have a package.json?


lagametv
FREEOP

10 months ago

ofc i do


irazvan2745
FREE

10 months ago

Well


irazvan2745
FREE

10 months ago

It’s not picking it up


lagametv
FREEOP

10 months ago

no shit


irazvan2745
FREE

10 months ago

Are you sure there is one on GitHub


lagametv
FREEOP

10 months ago

I somehow got it working using some configs in the Settings tab but I'm wondering if it's possible to make this work only using a railpack config.


irazvan2745
FREE

10 months ago

Or whatever your source is


irazvan2745
FREE

10 months ago

Can you share your package.json


lagametv
FREEOP

10 months ago

1432691998325735526


irazvan2745
FREE

10 months ago

Monorepo?


lagametv
FREEOP

10 months ago

yes

1432692149291585677


irazvan2745
FREE

10 months ago

I personally cd into the apps on railway when building them


lagametv
FREEOP

10 months ago

the problem is, that I need to run the generate in the root directory bc of prisma


irazvan2745
FREE

10 months ago

Cd after running it then


lagametv
FREEOP

10 months ago

looks like the /app dir is empty. Where does the code get cloned?

1432702280020394024


10 months ago

Can you try this in your build step? local

"build": {
      "inputs": [
        {
          "step": "install"
        },
        {
          "local": true
        }
      ],
      "commands": [
        "bun run db:generate && bun run --filter web build"
      ]
    }
  }

10 months ago

Also on install,

"install": {
      "inputs": [
        {
          "local": true,
          "include": [
            "package.json",
            "bun.lockb",
            "bun.lock"
          ]
        }
      ],
      "commands": [
        "bun install"
      ]
    }

lagametv
FREEOP

10 months ago

like this?

1432705326758629487


10 months ago

Try that


lagametv
FREEOP

10 months ago

1432705593982062692


10 months ago

sorry (put yoour desired bun version)

"install": {
        "inputs": [
          {
            "image": "oven/bun:latest"
          },
          {
            "local": true,
            "include": [
              "package.json",
              "bun.lockb",
              "bun.lock"
            ]
          }
        ],
        "commands": [
          "bun install"
        ]
      }

10 months ago

I also missed this, "local": {} instead of true


lagametv
FREEOP

10 months ago

at least the docker image pulled. idk. it feels like the code is just straight up missing or sth

1432708216114122782


10 months ago

Hmm


lagametv
FREEOP

10 months ago

and the other thing to keep in mind that it somehow worked with this config


lagametv
FREEOP

10 months ago

but I normally don't deploy on railpack directly thus this isn't a sutable option for me


10 months ago

You can generate a railpack from that service (with that config)


lagametv
FREEOP

10 months ago

how?


10 months ago

Click the service, and the latest deployment (with your desired config) then click Details.


lagametv
FREEOP

10 months ago

{
  "$schema": "https://railway.com/railway.schema.json",
  "build": {
    "builder": "RAILPACK",
    "buildCommand": "bun run db:generate && bun run --filter web build"
  },
  "deploy": {
    "runtime": "V2",
    "numReplicas": 1,
    "startCommand": "bun run --filter web start",
    "preDeployCommand": [
      "bun run db:migrate"
    ],
    "sleepApplication": false,
    "useLegacyStacker": false,
    "multiRegionConfig": {
      "europe-west4-drams3a": {
        "numReplicas": 1
      }
    },
    "restartPolicyType": "NEVER"
  }
}

lagametv
FREEOP

10 months ago

i'm not sure if that is railpack directly? looks like its some railway specific configuration


10 months ago

You are correct


10 months ago

My bad on that one


10 months ago

Have you tried explicitly including at the steps? Only thing that comes to mind now

1432710105538756658


lagametv
FREEOP

10 months ago

{
    "$schema": "https://schema.railpack.com/",
    "secrets": [
        "BETTER_AUTH_SECRET",
        "BETTER_AUTH_URL",
        "CORS_ORIGIN",
        "DATABASE_URL",
        "DISCORD_CLIENT_ID",
        "DISCORD_CLIENT_SECRET",
        "GOOGLE_CLIENT_ID",
        "GOOGLE_CLIENT_SECRET",
        "TWITCH_CLIENT_ID",
        "TWITCH_CLIENT_SECRET"
    ],
    "steps": {
        "install": {
            "inputs": [
                {
                    "image": "oven/bun:latest"
                },
                {
                    "local": true,
                    "include": ["."]
                }
            ],
            "commands": ["bun install"]
        },
        "build": {
            "inputs": [
                { "step": "install" },
                {
                    "local": true,
                    "include": ["."]
                }
            ],
            "secrets": ["BETTER_AUTH_URL", "CORS_ORIGIN", "DATABASE_URL"],
            "commands": ["bun run db:generate", "bun run --filter web build"]
        },
        "predeploy": {
            "inputs": [
                { "step": "build" },
                {
                    "local": true,
                    "include": ["."]
                }
            ],
            "commands": ["bun run db:migrate"]
        }
    },
    "deploy": {
        "startCommand": "bun run --filter web start",
        "variables": {
            "NODE_ENV": "production"
        }
    }
}

like this?


10 months ago

Yes


lagametv
FREEOP

10 months ago

<:PauseChamp:1287476240160260248> well its doing something

1432710620402290738



lagametv
FREEOP

10 months ago

<:mad:732129001111289866>

1432711459909009428


10 months ago

Okay this looks better


10 months ago

At least its picking up stuff


lagametv
FREEOP

10 months ago

yes. but this means that the packages did not install corretly


10 months ago

I need to drop off for a bit, I'd suggest you use the config that works in the meanwhile so you don't get more frustrated - I'll give this a shot once I'm back, also someone with more experience in Railpack might jump in and help


lagametv
FREEOP

10 months ago

tysm


10 months ago

<:salute:1137099685417451530>


10 months ago

any reason you need that custom railpack config in the first place?


lagametv
FREEOP

10 months ago

I'm trying to deploy using railpack on dokploy but I wasn't able to get my railpack running at all


10 months ago

ah I see. in most cases I would say it is not recommend to use a custom config file if possible since it lose out on several optimizations that railpack makes. in your case it looks like you just want to have a custom build and start command. I'm not sure the configuration options in Dokploy, but can you set these variables

  • RAILPACK_BUILD_CMD=bun run db:generate && bun run --filter web build && bun run db:migrate
  • RAILPACK_START_CMD=bun run --filter web start

lagametv
FREEOP

10 months ago

And the other thing I used the config for is the limitation of wich Secrets are shared in the different steps, as Better Auth spams me with those annoying "Do not include XYZ_SECRET in the build process..." messages


10 months ago

I see. can you try something like

{
  "$schema": "https://schema.railpack.com/",
  "secrets": [
    "BETTER_AUTH_SECRET",
    "BETTER_AUTH_URL",
    "CORS_ORIGIN",
    "DATABASE_URL",
    "DISCORD_CLIENT_ID",
    "DISCORD_CLIENT_SECRET",
    "GOOGLE_CLIENT_ID",
    "GOOGLE_CLIENT_SECRET",
    "TWITCH_CLIENT_ID",
    "TWITCH_CLIENT_SECRET"
  ],
  "steps": {
    "build": {
      "secrets": ["BETTER_AUTH_URL", "CORS_ORIGIN", "DATABASE_URL"],
      "commands": ["bun run db:generate", "bun run --filter web build"]
    },
    "predeploy": {
      "inputs": [{ "step": "build" }],
      "commands": ["bun run db:migrate"]
    }
  },
  "deploy": {
    "inputs": ["...", { "step": "predeploy", "include": ["."] }],
    "startCommand": "bun run --filter web start",
    "variables": {
      "NODE_ENV": "production"
    }
  }
}

the main changes

  • you don't need to include inputs unless you are changing them or they are non-default
  • you need to include the predeploy output in the final image

irazvan2745
FREE

10 months ago

You could also just use a dockerfile 🙂


lagametv
FREEOP

10 months ago

nah thats too easy tho


10 months ago

Did what was suggested work for you?


lagametv
FREEOP

10 months ago

this works up until the migration

1432831585325023232


10 months ago

Is the underscore in the host a typo? _


10 months ago

Can’t have underscores in the host name

1432837751543169054


lagametv
FREEOP

10 months ago

nah, autogenerated.

1432837818777997492

1432837819075788941


lagametv
FREEOP

10 months ago

okay interesting


10 months ago

Look in the Private Networking section for the proper endpoint


lagametv
FREEOP

10 months ago

let my try to remove the _


lagametv
FREEOP

10 months ago

now it should be "postgres.railway.internal". gimme a sec to deploy


lagametv
FREEOP

10 months ago

1432839284947161218


lagametv
FREEOP

10 months ago

nope <:SAJ:1398822528461438986>


10 months ago

Does it look like this in Settings -> Private Networking?

1432840599253553313


lagametv
FREEOP

10 months ago

1432843497592979516


10 months ago

the private network is not available when building at the moment. you can instead do the migration at the start. Change the start command to bun run db:migrate && bun run --filter web start


lagametv
FREEOP

10 months ago

I'll try that tomorrow


lagametv
FREEOP

10 months ago

okay, that seems to have worked on railway. but for some reason the migration fails on my dokploy instance.. <:confused:1031885128613511219>

1432999704437854240


lagametv
FREEOP

10 months ago

Amy idea how I could fix this?


lagametv
FREEOP

10 months ago

Looks like there are some files missing. Any Idea why?

That's my current config:

{
    "$schema": "https://schema.railpack.com/",
    "secrets": [
        "BETTER_AUTH_SECRET",
        "BETTER_AUTH_URL",
        "CORS_ORIGIN",
        "DATABASE_URL",
        "DISCORD_CLIENT_ID",
        "DISCORD_CLIENT_SECRET",
        "GOOGLE_CLIENT_ID",
        "GOOGLE_CLIENT_SECRET",
        "TWITCH_CLIENT_ID",
        "TWITCH_CLIENT_SECRET"
    ],
    "steps": {
        "build": {
            "commands": [
                "apt-get update && apt-get install -y tree && tree -I 'node_modules'",
                "bun run --filter @esc-plus-app/db db:generate -- --schema=$(pwd)/packages/db/prisma/schema/schema.prisma",
                "bun run --filter '*' build"
            ]
        },
        "predeploy": {
            "secrets": ["DATABASE_URL"],
            "inputs": [{ "step": "build" }],
            "commands": ["bun run --filter @esc-plus-app/db db:migrate"]
        }
    },
    "deploy": {
        "inputs": ["...", { "step": "predeploy", "include": ["."] }],
        "startCommand": "bun run --filter web start",
        "variables": {
            "NODE_ENV": "production"
        }
    }
}

1436357973810348082


lagametv
FREEOP

10 months ago

bump


lagametv
FREEOP

10 months ago

why are those files missing?


lagametv
FREEOP

10 months ago

why does this only copy the package.json and the prisma-dir? do I need to add a input to my first build step??

1438607756243239002


lagametv
FREEOP

10 months ago

pls help 🙏


Welcome!

Sign in to your Railway account to join the conversation.

Loading...