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/websiteas 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/websiteas 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 toCOPY ../.. /app/. - Some way to change the path at which the ENV Variables are loaded