Can we build a monorepo and create 2 services using nixpack toml file?

How will I do this?
Solution:
I solved it nvm. Skill issue with docker files
Jump to solution
37 Replies
Percy
Percy6mo ago
Project ID: N/A
KiBender
KiBenderOP6mo ago
N/A
Brody
Brody6mo ago
is this a shared or isolated monorepo?
KiBender
KiBenderOP6mo ago
Shared. I have common packages
Brody
Brody6mo ago
are you using something like turbo or nx?
KiBender
KiBenderOP6mo ago
Nop, simple pnpm I can use turbo if it helps
Brody
Brody6mo ago
pnpm workspaces?
KiBender
KiBenderOP6mo ago
Yes I have app/remix app/nest then lib/auth lib/db libs are shared
Brody
Brody6mo ago
sounds good, can you share your scripts object of your root package.json please
KiBender
KiBenderOP6mo ago
"test": "echo \"Error: no test specified\" && exit 1",
"build:libs": "pnpm --filter '@astral/*' build",
"predev": "pnpm run build:libs",
"prebuild": "pnpm run build:libs",
"dev": "dotenv -- shopify app dev --no-color",
"dev-remix": "dotenv -- pnpm run --filter=remix-app dev",
"dev-nest": "dotenv -- pnpm run --filter=nest-app start:dev",
"test:nest": "dotenv -- pnpm run --filter=nest-app test:watch",
"migrate": "dotenv -- pnpm run --filter=@astral/db migrate",
"generate": "dotenv -- pnpm run --filter=@astral/db generate",
"studio": "dotenv -- pnpm run --filter=@astral/db studio",
"shopify": "shopify",
"config:link": "shopify app config link",
"config:use": "shopify app config use",
"deploy": "shopify app deploy",
"codegen": "pnpm run --filter=remix-app graphql-codegen"
"test": "echo \"Error: no test specified\" && exit 1",
"build:libs": "pnpm --filter '@astral/*' build",
"predev": "pnpm run build:libs",
"prebuild": "pnpm run build:libs",
"dev": "dotenv -- shopify app dev --no-color",
"dev-remix": "dotenv -- pnpm run --filter=remix-app dev",
"dev-nest": "dotenv -- pnpm run --filter=nest-app start:dev",
"test:nest": "dotenv -- pnpm run --filter=nest-app test:watch",
"migrate": "dotenv -- pnpm run --filter=@astral/db migrate",
"generate": "dotenv -- pnpm run --filter=@astral/db generate",
"studio": "dotenv -- pnpm run --filter=@astral/db studio",
"shopify": "shopify",
"config:link": "shopify app config link",
"config:use": "shopify app config use",
"deploy": "shopify app deploy",
"codegen": "pnpm run --filter=remix-app graphql-codegen"
Brody
Brody6mo ago
looks like you have the applicable scripts to start remix and nest in dev mode, but are missing the scripts to start them in production mode?
KiBender
KiBenderOP6mo ago
I can add them, but its essentially migrate -> nest build -> nest start migrate -> remix build -> remix start How do I do it is I had build:nest start:nest and build:remix start:remix
Brody
Brody6mo ago
yep please add build and start scripts like you just mentioned for both apps that are geared to running the two apps in a production environment
KiBender
KiBenderOP6mo ago
I can add them, but can you continue what to do next? Imagine I have pnpm run build:nest pnpm run start:nest pnpm run build:remix pnpm run start:remix How do I configure in nixpack file for 2 services Can I have 2 nixpack files and 2 services build from 2 files?
Brody
Brody6mo ago
of course! you would need two railway services, but at this time im not thinking that you would need any nixpacks.toml files, you would just set the applicable build and start scripts in the given service setting
KiBender
KiBenderOP6mo ago
Aah understood. Thats what I'm doing now. But would really love if there is a way to write as code.
Brody
Brody6mo ago
you definitely could define them in separate nixpacks.toml or railway.json files, but you would then need to configure your railway services to use those config files, so in the end you still configure something in the service settings but if you would rather do it that way, id be happy to help
KiBender
KiBenderOP6mo ago
How do I setup 2 railway.toml file? A followup question, which one is better? nixpack /railway. I'm thinking in terms of speed of build
Brody
Brody6mo ago
i would personally go with a railway.json files instead of railway.toml or nixpacks.toml since the railway.json file has built in schema validation with your code editor you would have two files like nest_railway.json and remix_railway.json and then in the applicable service you would set the correct file in the service settings under the config-as-code section
KiBender
KiBenderOP6mo ago
Amazing. I didn't know you could pick a file. Thank you Also Can I get your recomendation on build speed? Docker, nixpack, something else?
Brody
Brody6mo ago
if it was me, i would go with a Dockerfile and pair it with railway's beta v2 builder but if you arent having any issues with nixpacks yet there isnt a good need to switch what are your current build times like for either app?
KiBender
KiBenderOP6mo ago
Somewhere around 15 mins for this project 6d0f799e-be59-4388-899d-f00456f30667 Why docker file?
Brody
Brody6mo ago
gives you far greater control over every step of the build
KiBender
KiBenderOP6mo ago
I dont have complaints about control atm.
Brody
Brody6mo ago
thats fair but im more so meaning you could likely hand craft a Dockerfile thats going to be leaner than the Dockerfile nixpacks makes, you could also most definably end up with a smaller container image what part of your builds take the longest? build or publish?
KiBender
KiBenderOP6mo ago
Oh Yeah that makes sense. If I remember correctly the build takes more time
Brody
Brody6mo ago
would you happen to know what stage of the build takes the longest? there should be timestamps printed throughout the logs
KiBender
KiBenderOP6mo ago
I'm not sure, going back and looking the recent builds seems faster. I do remember I had to wait around 15 mins
Brody
Brody6mo ago
i dont know much about your project but 15 minutes is a very long time though you also could have been caught up in a builder incident
KiBender
KiBenderOP6mo ago
Hi @Brody When we run build using docker files when do we run the migrate command?
Brody
Brody6mo ago
when do you run it with nixpacks?
KiBender
KiBenderOP6mo ago
During the start command
Brody
Brody6mo ago
perfect, do the same
KiBender
KiBenderOP6mo ago
Here my start command is the docker file itself Start the server using the production build CMD ["pnpm", "run", "--filter=remix-app", "start"] Thanks, I will try
KiBender
KiBenderOP6mo ago
What do I do. I'm using docker file to build. The docker image has pnpm but I think railway does not use that
No description
Solution
KiBender
KiBender6mo ago
I solved it nvm. Skill issue with docker files
Brody
Brody6mo ago
glad you where able to figure it out! (I was asleep)
Want results from more Discord servers?
Add your server