R
Railwayā€¢2y ago
drewbie

Trouble deploying monorepo app

I've been spinning my wheels for a while no trying to get my monorepo app to deploy and figured I'd come here to see if anyone could help out! Am I able to just run ts-node off of the monorepo source code and not have to compile any dependencies? My trouble seems to be trying to compile the app as the shared dependencies are not loading correctly. I realize this is more of a ts build config concern than a Railway concern, which is why I was leaning towards finding an approach that can just run the ts-node command off of the uncompiled code to just bypass this all together. I tried running railway up from the root of the monorepo, but I get a 413 saying that its too large. When I'm running up from the app directory/workspace itself, is that just uploading the code from that directory? The dependencies are handled at the top level of the monorepo so I'm just trying to wrap my head around what approach I should be taking. I've followed the guides, but still cant seem to get anywhere.
Any help is appreciated!
91 Replies
Percy
Percyā€¢2y ago
Project ID: d36cedc3-d1a4-453b-9e36-45d7299cabfd
drewbie
drewbieā€¢2y ago
d36cedc3-d1a4-453b-9e36-45d7299cabfd
angelo
angeloā€¢2y ago
how big are the contents of the repo?
drewbie
drewbieā€¢2y ago
The entire monorepo is large (1.6gb) with node_modules. The app trying to be deployed is much smaller. Not sure how to tell how large the app trying to be deployed and just its required dependencies is. Without node_modules its 195mb Latest deploy logs show it attempting the start command, but cant resolve the dependencies.
angelo
angeloā€¢2y ago
Yea, this shouldn't be failing on that first off
Percy
Percyā€¢2y ago
Flagging this thread. A team member will be with you shortly.
angelo
angeloā€¢2y ago
ok-
drewbie
drewbieā€¢2y ago
Should I be running railway link from within the app directory, or from the root? Currently there is only one app that is being deployed to Railway from the monorepo Appreciate your help btw!
angelo
angeloā€¢2y ago
well, one impossible problem at a time #10 0.478 /bin/bash: line 1: yarn: command not found Is your project a Deno project? Least we can do
drewbie
drewbieā€¢2y ago
One of the apps has deno deployed functions (supabase database), but not the one currently attempting to be deployed I switched that to a npm command, was a little thrown off yarn wasnt available
angelo
angeloā€¢2y ago
Okay, it seems to be that we are confusing the providers Can ya tell me how your monorepo is structured? Screenshot of the folder dir would be fine
drewbie
drewbieā€¢2y ago
drewbie
drewbieā€¢2y ago
expanded app is the one attempting to be deployed
angelo
angeloā€¢2y ago
Okay, so I have changed the root dir to /app
drewbie
drewbieā€¢2y ago
app is the directory for another app not being deployed to railway, do you mean relay?
angelo
angeloā€¢2y ago
oh! yes, relay meaning: you want /relay to be deployed
drewbie
drewbieā€¢2y ago
correct
angelo
angeloā€¢2y ago
cool, kicking off a build We really should ls after a failure like this šŸ˜ well, duh its packages/relay yea?
drewbie
drewbieā€¢2y ago
ah - im also running up locally since git doesnt have everything
angelo
angeloā€¢2y ago
yep, so you would up from that directory
angelo
angeloā€¢2y ago
Railway
Railway
Railway is an infrastructure platform where you can provision infrastructure, develop with that infrastructure locally, and then deploy to the cloud.
angelo
angeloā€¢2y ago
you just need your start command
drewbie
drewbieā€¢2y ago
yeah packages/relay
angelo
angeloā€¢2y ago
This is what I setup for ya btw
drewbie
drewbieā€¢2y ago
cool, so im yarn workspace relay railway up
angelo
angeloā€¢2y ago
no need for that just railway up after railway link
drewbie
drewbieā€¢2y ago
So the root directory was the missing bit? Nice, so looks like that was in prod, off the latest Github branch - while i was trying to deploye staging with local, shared code seemed to be what was going a little nuts
drewbie
drewbieā€¢2y ago
Railway
Railway
Railway is an infrastructure platform where you can provision infrastructure, develop with that infrastructure locally, and then deploy to the cloud.
angelo
angeloā€¢2y ago
Yes:
npm ERR! To see a list of scripts, run:
npm ERR! npm run
npm ERR! A complete log of this run can be found in:
npm ERR! /root/.npm/_logs/2022-11-15T20_45_55_076Z-debug-0.log
npm WARN config production Use `--omit=dev` instead.
npm ERR! Missing script: "start"
npm ERR! To see a list of scripts, run:
npm ERR! npm run
npm ERR! A complete log of this run can be found in:
npm ERR! /root/.npm/_logs/2022-11-15T20_45_55_076Z-debug-0.log
npm WARN config production Use `--omit=dev` instead.
npm ERR! Missing script: "start"
so you need to specify your start command
drewbie
drewbieā€¢2y ago
Thats off of main on Github, im trying to run up locally to staging, which has a start command
angelo
angeloā€¢2y ago
npm start --filter=relay only makes sense in the context of your yarn workspace gotcha OH ok
angelo
angeloā€¢2y ago
angelo
angeloā€¢2y ago
So whats happening here is that your Railway up in the package folder is messing with the setting thats fine can ya run railway up from root?
drewbie
drewbieā€¢2y ago
Ok - back to the 413 error
drewbie
drewbieā€¢2y ago
angelo
angeloā€¢2y ago
are node modules in your git ignore?
drewbie
drewbieā€¢2y ago
yeah
angelo
angeloā€¢2y ago
wondering why we are trying to ship that šŸ˜ I made an empty service for ya, can ya up in the directory to nice-sign
drewbie
drewbieā€¢2y ago
Ah yep, same 413
angelo
angeloā€¢2y ago
within packages/relay not root
angelo
angeloā€¢2y ago
Railway
Railway
Railway is an infrastructure platform where you can provision infrastructure, develop with that infrastructure locally, and then deploy to the cloud.
angelo
angeloā€¢2y ago
It should go to this service, not the one linked to the GH repo you might need to run railway link again possibly
drewbie
drewbieā€¢2y ago
Im able to select nice-sign as the project, but up gives the 413
angelo
angeloā€¢2y ago
within the relay package folder? or root
drewbie
drewbieā€¢2y ago
root
angelo
angeloā€¢2y ago
yes, you need to cd to packages/relay and then run up The mental model to think about it here is, in your monorepo, each of your packages is a service. For your local dev, doing railway up just throws up your whole directory for us to build so at the end of this In a perfect world: you would have your git repo with a different root directory for each of your services. I saw that
ā•”ā•ā•ā•ā•ā•ā•ā•ā•ā• Nixpacks v0.14.0 ā•ā•ā•ā•ā•ā•ā•ā•ā•—
ā•‘ setup ā”‚ nodejs-16_x, npm-8_x ā•‘
ā•‘ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā•‘
ā•‘ install ā”‚ npm i ā•‘
ā•‘ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā•‘
ā•‘ build ā”‚ npm run build ā•‘
ā•‘ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā•‘
ā•‘ start ā”‚ npm run start ā•‘
ā•šā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•
ā•”ā•ā•ā•ā•ā•ā•ā•ā•ā• Nixpacks v0.14.0 ā•ā•ā•ā•ā•ā•ā•ā•ā•—
ā•‘ setup ā”‚ nodejs-16_x, npm-8_x ā•‘
ā•‘ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā•‘
ā•‘ install ā”‚ npm i ā•‘
ā•‘ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā•‘
ā•‘ build ā”‚ npm run build ā•‘
ā•‘ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā•‘
ā•‘ start ā”‚ npm run start ā•‘
ā•šā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•
drewbie
drewbieā€¢2y ago
Different root in git not being packages/name like now you mean?
drewbie
drewbieā€¢2y ago
Railway
Railway
Railway is an infrastructure platform where you can provision infrastructure, develop with that infrastructure locally, and then deploy to the cloud.
angelo
angeloā€¢2y ago
new errors are good Looking at logs Do you have a dep that is outside of your package?
drewbie
drewbieā€¢2y ago
Ill need to create a build command that puts all dependencies for relay within its directory though? Yes, relay imports some of the shared packages from the monorepo
angelo
angeloā€¢2y ago
yep, thats where its failing Lets see if there is a better way where you don't have to do that one sec, thinking
drewbie
drewbieā€¢2y ago
Which is where I started with trying to do all of this from root so that the node modules were all set up like local
angelo
angeloā€¢2y ago
Yea, I understand what you are trying to get at Talking to the team, one sec. If ya can, I understand if ya can't, can ya make the repo public or invite coffee-cup?
drewbie
drewbieā€¢2y ago
I can invite someone
angelo
angeloā€¢2y ago
cool also, can ya drop your root package.json and the one in packages/relay
drewbie
drewbieā€¢2y ago
root
{
"name": "paintball-vault",
"version": "0.0.0",
"private": true,
"workspaces": [
"packages/*"
],
"scripts": {
"dev": "turbo run dev",
"dev:backend": "yarn dev --filter=backend --filter=search --filter=relay",
"seed:backend": "yarn seed --filter=backend --filter=search",
"seed": "turbo run seed",
"build": "turbo run build",
"test": "turbo run test",
"lint": "turbo run lint",
"start": "turbo run start",
"types": "turbo run types",
"backend": "yarn workspace backend",
"app": "yarn workspace app",
"web": "yarn workspace web",
"clean": "echo \"Running clean in root\" && yarn clean:turbo && echo \"Running yarn cache clean\" && rm -rf yarn.lock && yarn cache clean",
"clean:turbo": "turbo run clean && rm -rf node_modules"
},
"devDependencies": {
"turbo": "1.4.7"
},
"engines": {
"node": ">=16.10.0"
},
"packageManager": "yarn@1.22.17"
}
{
"name": "paintball-vault",
"version": "0.0.0",
"private": true,
"workspaces": [
"packages/*"
],
"scripts": {
"dev": "turbo run dev",
"dev:backend": "yarn dev --filter=backend --filter=search --filter=relay",
"seed:backend": "yarn seed --filter=backend --filter=search",
"seed": "turbo run seed",
"build": "turbo run build",
"test": "turbo run test",
"lint": "turbo run lint",
"start": "turbo run start",
"types": "turbo run types",
"backend": "yarn workspace backend",
"app": "yarn workspace app",
"web": "yarn workspace web",
"clean": "echo \"Running clean in root\" && yarn clean:turbo && echo \"Running yarn cache clean\" && rm -rf yarn.lock && yarn cache clean",
"clean:turbo": "turbo run clean && rm -rf node_modules"
},
"devDependencies": {
"turbo": "1.4.7"
},
"engines": {
"node": ">=16.10.0"
},
"packageManager": "yarn@1.22.17"
}
relay
{
"name": "relay",
"version": "0.0.0",
"main": "index.ts",
"private": true,
"scripts": {
"dev": "ts-node ./index.ts",
"start": "ts-node ./index.ts",
"build": "echo 'build'"
},
"dependencies": {
"pg-listen": "1.7.0",
"email": "*",
"search": "*",
"shared": "*"
},
"devDependencies": {
"@railway/cli": "2.0.13",
"ts-node": "10.9.1",
"typescript": "4.8.4"
}
}
{
"name": "relay",
"version": "0.0.0",
"main": "index.ts",
"private": true,
"scripts": {
"dev": "ts-node ./index.ts",
"start": "ts-node ./index.ts",
"build": "echo 'build'"
},
"dependencies": {
"pg-listen": "1.7.0",
"email": "*",
"search": "*",
"shared": "*"
},
"devDependencies": {
"@railway/cli": "2.0.13",
"ts-node": "10.9.1",
"typescript": "4.8.4"
}
}
drewbie
drewbieā€¢2y ago
GitHub
coffee-cup - Overview
ā™„ļø web and iOS. coffee-cup has 156 repositories available. Follow their code on GitHub.
drewbie
drewbieā€¢2y ago
Assuming so since I see some railway activity on there
angelo
angeloā€¢2y ago
Wait not yet! We think if we fix the 413 you should be good to go I think up doesn't support all the turporepo goodness we have built out... so you would have to up from root, but I am just confused why we think its too large okay, I guess we found the culprit can you add a .railwayignore and add node_modules to that
drewbie
drewbieā€¢2y ago
in root or in relay?
angelo
angeloā€¢2y ago
in addition, can you make sure that you add any node_modules folder to be ignored within any sub-directory? in root
drewbie
drewbieā€¢2y ago
Yeah just double checked the .gitignore's - they all have node_modules Hmm still get the 413 with all of that
angelo
angeloā€¢2y ago
strange... I don't know what else to do here except to tell you to commit your work to main in the meantime, we have a 1 Gb upload limit and something is running into that at least the git config is working, just confused why the CLI isn't working
drewbie
drewbieā€¢2y ago
Hmm ok - anyway to run it off this branch instead of main so i dont have to merge?
angelo
angeloā€¢2y ago
Yes, lemme point you to that setting
angelo
angeloā€¢2y ago
angelo
angeloā€¢2y ago
under service settings and then your branch
drewbie
drewbieā€¢2y ago
hmm - i just deleted every node_module folder and ran the railway cli after installing it globally and still get the 413 can confirm entire directory is 385mb after doing that
angelo
angeloā€¢2y ago
Gotcha, might be an updated limit or something. I will talk to a team member about this and get resolution there. However, in all fairness, it likely won't be fixed soon. (You should at least have the documented limit.)
drewbie
drewbieā€¢2y ago
Would my best bet being trying to figure out a build command that includes all of relays dependencies and deploying just that? and bypass the monorepo as much as possible
angelo
angeloā€¢2y ago
well, with railway up we only up the local folder- I would honestly just stick with the git flow to even take advantage of all the cool stuff you get out of your exisiting workflow Any reason to the (percieved, making an assumption here) adversion to deploying your working branch for dev? This would work for the record, just don't want you to do pointless work if you don't have to.
drewbie
drewbieā€¢2y ago
No adversion there - was just doing it locally for quicker feedback but can push to the branch to test out instead
angelo
angeloā€¢2y ago
Gotcha- code is glass making I feel. The shorter the cycle the better. Lets get the base case up and running and then we can move ya over to the CLI. We will have some internal discussions in the meantime.
drewbie
drewbieā€¢2y ago
Should I be able to run yarn commands with my setup? I know early on you were saying it detected the wrong project type Trying to get back to using the git workflow, with normal yarn commands but back to the yarn command not founds bits
angelo
angeloā€¢2y ago
You should Looking into it, one sec So is there a Dockerfile in that repo?
drewbie
drewbieā€¢2y ago
There is - noticed when I switched the root directory it picked up the dockerfile
angelo
angeloā€¢2y ago
do you want to use Docker?
drewbie
drewbieā€¢2y ago
I may end up doing that - the last deploy just worked using it
angelo
angeloā€¢2y ago
Wanna jump on a meet? I think a high bandwith convo like this can be solved quickly over a call
drewbie
drewbieā€¢2y ago
Yeah that works!
angelo
angeloā€¢2y ago
spinning it up
angelo
angeloā€¢2y ago
\
drewbie
drewbieā€¢2y ago
Ok - brain busting. This build compared to the most recent is able to find the dependencies, with the same commands? https://railway.app/project/d36cedc3-d1a4-453b-9e36-45d7299cabfd/service/d6fef121-dc63-46e1-85ae-a9c75f47dbfc?id=bd6fbf48-0551-4ca1-a72e-cd93ed34dc23
Railway
Railway
Railway is an infrastructure platform where you can provision infrastructure, develop with that infrastructure locally, and then deploy to the cloud.
angelo
angeloā€¢2y ago
Oh this is just weird?
drewbie
drewbieā€¢2y ago
Yeah tried adding the env var and redeploying and its back to the dependency missing bits
angelo
angeloā€¢2y ago
added: NIXPACKS_NO_CACHE I hope its not an issue with our builder reusing an old busted image Okay, it was cache, ofc
drewbie
drewbieā€¢2y ago
So for my own sanity - did the build command need tsc or could it be stubbed? I think we were debugging with it stubbed - I jsut redployed this working one and it worked - https://railway.app/project/d36cedc3-d1a4-453b-9e36-45d7299cabfd/service/d6fef121-dc63-46e1-85ae-a9c75f47dbfc?id=aae3a9be-9d87-4137-81ff-6b9a0b59f806
Railway
Railway
Railway is an infrastructure platform where you can provision infrastructure, develop with that infrastructure locally, and then deploy to the cloud.
angelo
angeloā€¢2y ago
Should be fine moving forward
drewbie
drewbieā€¢2y ago
Hmm yeah - only promoting that old one seems to be working šŸ¤”