Caddy in a monorepo?

kevmok
HOBBY

a year ago

I was following your template <@539512869780455445> to deploy vite with Caddy https://github.com/brody192/vite-react-template/blob/main/Caddyfile in my monorepo but I think my nixpacks.toml is not getting picked up.

f78d75b5-8972-4d61-8517-22bbccefb41e

I created a file for my landing page in deployments/landing-nixpacks.toml

# https://nixpacks.com/docs/configuration/file

# set up some variables to minimize annoyance
[variables]
NPM_CONFIG_UPDATE_NOTIFIER = 'false' # the update notification is relatively useless in a production environment
NPM_CONFIG_FUND = 'false'            # the fund notification is also pretty useless in a production environment

[phases.build]
cmds = ['pnpm --filter landing build']

# download caddy from nix
[phases.caddy]
dependsOn = [
    'setup',
] # make sure this phase runs after the default 'setup' phase
nixpkgsArchive = 'ba913eda2df8eb72147259189d55932012df6301' # Caddy v2.8.4 - https://github.com/NixOS/nixpkgs/commit/ba913eda2df8eb72147259189d55932012df6301
nixPkgs = ['caddy'] # install caddy as a nix package

# format the Caddyfile with fmt
[phases.fmt]
dependsOn = [
    'caddy',
] # make sure this phase runs after the 'caddy' phase so that we know we have caddy downloaded
cmds = [
    'caddy fmt --overwrite Caddyfile',
] # format the Caddyfile to fix any formatting inconsistencies

# start the caddy web server
[start]
cmd = 'exec caddy run --config apps/landing/Caddyfile --adapter caddyfile 2&gt;&amp;1' # start caddy using the Caddyfile config and caddyfile adapter

But i noticed the configs in the service settings are not getting overriden :/

0 Replies

a year ago

values in the nixpacks.toml file can not overwrite anything in the service settings


kevmok
HOBBY

a year ago

<:cat_woah:1119125214723326072>


a year ago

you are thinking of a railway.json file


kevmok
HOBBY

a year ago

that's true


a year ago

but other than that what makes you think it's not being used? have you checked the build table?


kevmok
HOBBY

a year ago

i see there's a nixpacksConfigPath in the railway config maybe ill try that


kevmok
HOBBY

a year ago

yeah


kevmok
HOBBY

a year ago

1274168897825935400


a year ago

you shouldn't need that


a year ago

perhaps you have not set the root directory correctly?


a year ago

have you read my guide? -


kevmok
HOBBY

a year ago

Yea quite a bit, this is a shared package monorepo so that wouldn't work


a year ago

gotcha


a year ago

what are you using? nx, turbo?


kevmok
HOBBY

a year ago

turbo


kevmok
HOBBY

a year ago

adding the nixpacksconfigpath might be working'


kevmok
HOBBY

a year ago

1274169784237428700


a year ago

you may need to adjust the the root directory in the Caddyfile


kevmok
HOBBY

a year ago

yeah for formatting i think this might work


kevmok
HOBBY

a year ago

looks like it deployed

1274171043136934000


kevmok
HOBBY

a year ago

waiting on website to appear 🤞 https://landing-production-7ab3.up.railway.app


a year ago

there is no waiting, that is a 404 that caddy is returning


kevmok
HOBBY

a year ago

Oh 😭


a year ago

^


kevmok
HOBBY

a year ago

Yeah that’s what I’m trying to figure out. I thought caddy run apps/landing/Caddyfile was the way to do it


kevmok
HOBBY

a year ago

I see, i tested locally and i also get a blank page


kevmok
HOBBY

a year ago

the fix was to fix this line in the Caddyfile

    root * apps/landing/dist

a year ago

i was right 🙂


kevmok
HOBBY

a year ago

always


kevmok
HOBBY

a year ago

i never worked with caddy so didnt understand at first


kevmok
HOBBY

a year ago

thanks!


a year ago

no problem!