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

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

$10 Bounty

75 Replies

irazvan2745
FREE

4 months ago

You don’t have a package.json?


lagametv
FREEOP

4 months ago

ofc i do


irazvan2745
FREE

4 months ago

Well


irazvan2745
FREE

4 months ago

It’s not picking it up


lagametv
FREEOP

4 months ago

no shit


irazvan2745
FREE

4 months ago

Are you sure there is one on GitHub


lagametv
FREEOP

4 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

4 months ago

Or whatever your source is


irazvan2745
FREE

4 months ago

Can you share your package.json


lagametv
FREEOP

4 months ago

1432691998325735400


irazvan2745
FREE

4 months ago

Monorepo?


lagametv
FREEOP

4 months ago

yes

1432692149291585800


irazvan2745
FREE

4 months ago

I personally cd into the apps on railway when building them


lagametv
FREEOP

4 months ago

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


irazvan2745
FREE

4 months ago

Cd after running it then


lagametv
FREEOP

4 months ago

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

1432702280020394000


4 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"
      ]
    }
  }

4 months ago

Also on install,

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

lagametv
FREEOP

4 months ago

like this?

1432705326758629400


4 months ago

Try that


lagametv
FREEOP

4 months ago

1432705593982062600


4 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"
        ]
      }

4 months ago

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


lagametv
FREEOP

4 months ago

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

1432708216114122800


4 months ago

Hmm


lagametv
FREEOP

4 months ago

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


lagametv
FREEOP

4 months ago

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


4 months ago

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


lagametv
FREEOP

4 months ago

how?


4 months ago

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


lagametv
FREEOP

4 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

4 months ago

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


4 months ago

You are correct


4 months ago

My bad on that one


4 months ago

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

1432710105538756600


lagametv
FREEOP

4 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?


4 months ago

Yes


lagametv
FREEOP

4 months ago

<:PauseChamp:1287476240160260248> well its doing something

1432710620402290700



lagametv
FREEOP

4 months ago

<:mad:732129001111289866>

1432711459909009400


4 months ago

Okay this looks better


4 months ago

At least its picking up stuff


lagametv
FREEOP

4 months ago

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


4 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

4 months ago

tysm


4 months ago

<:salute:1137099685417451530>


4 months ago

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


lagametv
FREEOP

4 months ago

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


4 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

4 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


4 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

4 months ago

You could also just use a dockerfile 🙂


lagametv
FREEOP

4 months ago

nah thats too easy tho


4 months ago

Did what was suggested work for you?


lagametv
FREEOP

4 months ago

this works up until the migration

1432831585325023200


4 months ago

Is the underscore in the host a typo? _


4 months ago

Can’t have underscores in the host name

1432837751543169000


lagametv
FREEOP

4 months ago

nah, autogenerated.

1432837818777997600
1432837819075789000


lagametv
FREEOP

4 months ago

okay interesting


4 months ago

Look in the Private Networking section for the proper endpoint


lagametv
FREEOP

4 months ago

let my try to remove the _


lagametv
FREEOP

4 months ago

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


lagametv
FREEOP

4 months ago

1432839284947161300


lagametv
FREEOP

4 months ago

nope <:SAJ:1398822528461438986>


4 months ago

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

1432840599253553400


lagametv
FREEOP

4 months ago

1432843497592979500


4 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

4 months ago

I'll try that tomorrow


lagametv
FREEOP

4 months ago

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

1432999704437854200


lagametv
FREEOP

4 months ago

Amy idea how I could fix this?


lagametv
FREEOP

4 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"
        }
    }
}

1436357973810348000


lagametv
FREEOP

4 months ago

bump


lagametv
FREEOP

4 months ago

why are those files missing?


lagametv
FREEOP

4 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??

1438607756243239000


lagametv
FREEOP

4 months ago

pls help 🙏


Loading...