App not detecting environment variables on start
trackingtrade
ENTERPRISEOP

10 months ago

I'm trying to deploy a monorepo with pnpm workspaces and nextJS web app.

The database is in packages/db, and I'm trying to use drizzle-kit to run migrations upon app start.

For some reason, it doesn't pick up on any of my environment variables, and it fails because it cannot find my DATABASE_URL.

I've spent way to much time on this, and it doesn't seem to be anything on my side. This is stupid. It shouldn't be this hard to deploy an app on railway.

Here's my railway.json:

{
  "$schema": "https://railway.app/railway.schema.json",
  "build": {
    "builder": "RAILPACK",
    "watchPatterns": [
      "apps/web/**",
      "packages/**",
      "turbo.json",
      "package.json",
      "pnpm-lock.yaml",
      "pnpm-workspace.yaml",
      "railpack.json",
      "railway.json"
    ]
  },
  "deploy": {
    "numReplicas": 1,
    "sleepApplication": false,
    "restartPolicyType": "ON_FAILURE",
    "restartPolicyMaxRetries": 10,
    "startCommand": "pnpm db:migrate --filter=@lg-monorepo/db && pnpm --filter=web start"
  }
}
$10 Bounty

2 Replies

Railway
BOT

10 months ago


10 months ago

This thread has been marked as public for community involvement, as it does not contain any sensitive or personal information. Any further activity in this thread will be visible to everyone.

Status changed to Open noahd 10 months ago


10 months ago

Hi,

This likely won't fix your issue but I'd like to note that migration steps belong in pre-deploy steps.

https://docs.railway.com/guides/pre-deploy-command


Welcome!

Sign in to your Railway account to join the conversation.

Loading...