R
Railway4mo 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
Percy4mo ago
Project ID: 6b3f7e42-b250-4b53-8639-abb14c79ab8b
Sam
Sam4mo ago
6b3f7e42-b250-4b53-8639-abb14c79ab8b/service/91591431-792c-40cc-a0f2-16510cdd15e1
Brody
Brody4mo 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
Sam4mo 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
Sam4mo ago
No description
Sam
Sam4mo ago
maybe thats not how it works but for some reason it cant load the right vars
Brody
Brody4mo ago
environment variables aren't scoped to anything
Sam
Sam4mo ago
Ok, ill keep looking into it further thanks
Brody
Brody4mo ago
id be happy to help, but theres not too much i can help with if theres no error messages
Solution
Brody
Brody4mo 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
Sam4mo 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
Brody4mo ago
no problem!
Want results from more Discord servers?
Add your server
More Posts
Issuing TLS certificate taking too much timehello, i'm trying to use a custom domain for a deployed project, I added the CNAME record as directeno such file or directory, open '/root/.cache/node/corepack/lastKnownGI am getting this error "0.448 Internal Error: ENOENT: no such file or directory, open '/root/.cacheDatabase postgres buggedHi, i change the password from my database postgres, and now he dont connect more, using pgadmin he how to get railway to reissue SSL certHey guys, is there a way to do this? In my Service -> Settings -> Networking it says it is issuing dev vs prod instance tracking different branches?how would I create another railway instance from the same repo, but listening to a different branch?building got a error, but It was ok before...#11 [stage-0 7/11] RUN --mount=type=cache,id=s/6195fab7-3631-4239-bd50-6ededa78afb2-/root/local/shaBuild Failed After Change to Dockerfile Then Back to Nixpacks BuilderHello, I am trying to deploy my turborepo apps with Dockerfile, but it seems not successful yet. So,Add sitemap xml for google search console with railway (Django Framework)Hello I have a website i built on Django and the sitemap i generated online for this website. Do i hCache mounts MUST be in the format --mount=type=cache,id=<cache-id>New to railway, trying to deploy a docker image which builds a Node app. The quickstart from github How to I set protocol from SSL, to TLS V.1.2?Hi, i'm getting an error, reference to a version from my protocol tls, would there be any way to sel