Caddyfile nested in shared monorepo not being found by nixpacks

drolatic-labs
HOBBY

3 days ago

Hi, I've got a bit of a head-scratcher with nixpacks + caddy. I know it's not directly Railway, but I've run out of leads.

I've got a shared monorepo looking something like this:

├── apps/
  │   ├── client/
  │   │   ├── dist/
  │   │   ├── public/
  │   │   └── src/
  │   └── server/
  │       ├── dist/
  │       └── src/
  └─ packages/

Issue #1

I've added 2 nixpacks.toml in their respective client and server folders and have deployed them separately using repo root and custom build/start paths.

The client is a vite app, and for reasons unknown neither out-of-box nixpack nor railpack can recognize it as a vite project and serve it with caddy (I suspect the folder nesting is causing some issues).

My first question is: is there some setting I'm missing for the default builders to detect vite as a static site in a shared monorepo? I've had no issue when vite is setup in the root.

Issue #2

Anyways, I kept chugging along by doing it the old fashioned way by setting up caddy to explicitly serve it. However, I could not get the nixpacks.toml to recognize the Caddyfile when I put them both in apps/client "Error: No start command could be found." I tried every relative and absolute path in the nixpack caddy cmds, and none of them recognize it.

Weird thing is, I have no problems when I put both files in the repo root (and specify the config path in settings). I also have no problems when I place just the Caddyfile in the apps/client folder, and use relative paths from my nixpacks.toml to reference caddy commands:

  • cmds = ['caddy fmt --overwrite apps/client/Caddyfile']

  • cmd = 'exec caddy run --config apps/client/Caddyfile --adapter caddyfile 2>&1'

It's specifically having them adjacent in a nested folder where things get weird.

TIA.

Solved

2 Replies

Railway
BOT

3 days ago

Hey there! We've found the following might help you get unblocked faster:

If you find the answer from one of these, please let us know by solving the thread!


drolatic-labs
HOBBY

3 days ago

Ok thanks Railway Bot you've done it again. The link above seems to have had the answer.

Specifically, it refers to this: https://docs.railway.com/reference/config-as-code#nixpacks-config-path, where you are supposed to use a railway config file in addition to a nixpacks file for any custom setup, including monorepo shenanigans where nested folders might not work with railway's project auto-detection.

NGL that was incredibly time-consuming to debug and seems a little arbitrary, but I'm sure there's a reason to RTFM.

I'll leave this up if anyone has any input on my vite-within-monorepo not being recognized, but I'm unblocked for the most part.


Status changed to Solved brody 3 days ago