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

a month 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
PRO

a month ago

You don’t have a package.json?


lagametv
FREEOP

a month ago

ofc i do


irazvan2745
PRO

a month ago

Well


irazvan2745
PRO

a month ago

It’s not picking it up


lagametv
FREEOP

a month ago

no shit


irazvan2745
PRO

a month ago

Are you sure there is one on GitHub


lagametv
FREEOP

a month 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
PRO

a month ago

Or whatever your source is


irazvan2745
PRO

a month ago

Can you share your package.json


lagametv
FREEOP

a month ago

1432691998325735400


irazvan2745
PRO

a month ago

Monorepo?


lagametv
FREEOP

a month ago

yes

1432692149291585800


irazvan2745
PRO

a month ago

I personally cd into the apps on railway when building them


lagametv
FREEOP

a month ago

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


irazvan2745
PRO

a month ago

Cd after running it then


lagametv
FREEOP

a month ago

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

1432702280020394000


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

Also on install,

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

lagametv
FREEOP

a month ago

like this?

1432705326758629400


Try that


lagametv
FREEOP

a month ago

1432705593982062600


sorry (put yoour desired bun version)

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

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


lagametv
FREEOP

a month ago

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

1432708216114122800



lagametv
FREEOP

a month ago

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


lagametv
FREEOP

a month ago

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


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


lagametv
FREEOP

a month ago

how?


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


lagametv
FREEOP

a month 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

a month ago

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


You are correct


My bad on that one


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

1432710105538756600


lagametv
FREEOP

a month 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?



lagametv
FREEOP

a month ago

<:PauseChamp:1287476240160260248> well its doing something

1432710620402290700



lagametv
FREEOP

a month ago

<:mad:732129001111289866>

1432711459909009400


Okay this looks better


At least its picking up stuff


lagametv
FREEOP

a month ago

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


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

a month ago

tysm


<:salute:1137099685417451530>


jr
EMPLOYEE

a month ago

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


lagametv
FREEOP

a month ago

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


jr
EMPLOYEE

a month 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

a month 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


jr
EMPLOYEE

a month 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
PRO

a month ago

You could also just use a dockerfile 🙂


lagametv
FREEOP

a month ago

nah thats too easy tho


Did what was suggested work for you?


lagametv
FREEOP

a month ago

this works up until the migration

1432831585325023200


Is the underscore in the host a typo? _


Can’t have underscores in the host name

1432837751543169000


lagametv
FREEOP

a month ago

nah, autogenerated.

1432837818777997600
1432837819075789000


lagametv
FREEOP

a month ago

okay interesting


Look in the Private Networking section for the proper endpoint


lagametv
FREEOP

a month ago

let my try to remove the _


lagametv
FREEOP

a month ago

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


lagametv
FREEOP

a month ago

1432839284947161300


lagametv
FREEOP

a month ago

nope <:SAJ:1398822528461438986>


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

1432840599253553400


lagametv
FREEOP

a month ago

1432843497592979500


jr
EMPLOYEE

a month 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

a month ago

I'll try that tomorrow


lagametv
FREEOP

a month 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

a month ago

Amy idea how I could fix this?


lagametv
FREEOP

a month 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

a month ago

bump


lagametv
FREEOP

a month ago

why are those files missing?


lagametv
FREEOP

25 days 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

25 days ago

pls help 🙏


Loading...