R
Railway10mo ago
Sam

Issues with Root Directory and NextJS deployment in Turbo repo

I have a turbo monorepo with a Next app I am trying to deploy. I need the paths for deployment to be as follows: Deploy: ./apps/website Build: ./ Install: ./ Variables: ./apps/website Solution 1 - Set the Root Directory as ./ - Set the install phase cmd to npm install (executes in ./ as desired) - Set the buildCommand to npm run build (executes in ./ as desired) - Set the startCommand to npm run --prefix ./apps/website start (executes in ./apps/website as desired) Problem: It attempts to load the ENV Variables at ./apps/website when Railway thinks they are at ./ since thats what was specified as the Root Directory Solution 2 (Ideal solution) - Set the Root Directory as ./apps/website - Set the install phase cmd to npm install --prefix ../.. - Set the buildCommand to npm run --prefix ../.. build - Set the startCommand to npm run start (executes in ./apps/website as desired) Problem: Railway seems to do some COPY . /app/. process which makes any path outside the specified Root Directory inaccessible (ie ../../package.json or the path ./package.json in my monorepo does not exist) and therefore impossible to execute the install and build commands in the right path Solution 2 is my idea situation since it scopes the deployment to the code that I want, this is how it works on Vercel. I guess the two potential changes I would need are either: - (ideal) Some way to change the directory at which Railway runs the COPY . /app/. command to COPY ../.. /app/. - Some way to change the path at which the ENV Variables are loaded
Solution:
but your solution 1 would be the most applicable solution, with the exception that your install and build commands are filtered to only insall and build the apps/website app
Jump to solution
12 Replies
Percy
Percy10mo ago
Project ID: 6b3f7e42-b250-4b53-8639-abb14c79ab8b
Sam
SamOP10mo ago
6b3f7e42-b250-4b53-8639-abb14c79ab8b/service/91591431-792c-40cc-a0f2-16510cdd15e1
Brody
Brody10mo ago
Problem: It attempts to load the ENV Variables at ./apps/website when Railway thinks they are at ./ since thats what was specified as the Root Directory
and
Some way to change the path at which the ENV Variables are loaded
im not sure what these paths have to do with environment variables, could you please explain that?
Sam
SamOP10mo ago
Yeah so if I specify ./ as the Root Directory in the Railway dashboard its my assumption that Railway is attempting to load any Variables set in the dashboard at the path ./. However, I am deploying from the path ./apps/website which is likely why it cant find those variables? This recent deployment fails because it cant load the ENV variables https://monorepo-production-610d.up.railway.app/
No description
Sam
SamOP10mo ago
No description
Sam
SamOP10mo ago
maybe thats not how it works but for some reason it cant load the right vars
Brody
Brody10mo ago
environment variables aren't scoped to anything
Sam
SamOP10mo ago
Ok, ill keep looking into it further thanks
Brody
Brody10mo ago
id be happy to help, but theres not too much i can help with if theres no error messages
Solution
Brody
Brody10mo ago
but your solution 1 would be the most applicable solution, with the exception that your install and build commands are filtered to only insall and build the apps/website app
Sam
SamOP10mo ago
Got it Figured out the issue was I was using the wrong branch which had a slightly different name for one of the vars, my apologies. I appreciate your time.
Brody
Brody10mo ago
no problem!
Want results from more Discord servers?
Add your server