Caddy in a monorepo?
kevmok
PROOP

2 years 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 :/

32 Replies

2 years ago

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


kevmok
PROOP

2 years ago

<:cat_woah:1119125214723326072>


2 years ago

you are thinking of a railway.json file


kevmok
PROOP

2 years ago

that's true


2 years ago

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


kevmok
PROOP

2 years ago

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


kevmok
PROOP

2 years ago

yeah


kevmok
PROOP

2 years ago

1274168897825935400


2 years ago

you shouldn't need that


2 years ago

perhaps you have not set the root directory correctly?


2 years ago

have you read my guide? -


kevmok
PROOP

2 years ago

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


2 years ago

gotcha


2 years ago

what are you using? nx, turbo?


kevmok
PROOP

2 years ago

turbo


kevmok
PROOP

2 years ago

adding the nixpacksconfigpath might be working'


kevmok
PROOP

2 years ago

1274169784237428700


2 years ago

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


kevmok
PROOP

2 years ago

yeah for formatting i think this might work


kevmok
PROOP

2 years ago

looks like it deployed

1274171043136934000


kevmok
PROOP

2 years ago

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


2 years ago

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


kevmok
PROOP

2 years ago

Oh 😭


2 years ago

^


kevmok
PROOP

2 years 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
PROOP

2 years ago

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


kevmok
PROOP

2 years ago

the fix was to fix this line in the Caddyfile

    root * apps/landing/dist

2 years ago

i was right 🙂


kevmok
PROOP

2 years ago

always


kevmok
PROOP

2 years ago

i never worked with caddy so didnt understand at first


kevmok
PROOP

2 years ago

thanks!


2 years ago

no problem!


Loading...