4 months ago
Greets! Love Railway… so much easier than GCP . But only don't love how long it takes to deploy containers. My svelte4 app takes almost 5 mins to build and deploy, with about 1/3 being just deploying. I'm not sure what is up.. on netlify it's about half the time, same code. Wondering what I can do to speed things up somewhat. Any tips appreciated, if documented somewhere. Maybe there are some extra checks for prod etc that I can disable in my staging env so I can get to testing it faster.
Project ID : 7ff52821-b7d2-459c-bff8-3f070394a82b
0 Replies
Note that, there's nothing wrong. The deploy works fine without any errors or warnings and the app works fine. It's just…. slow to get there. Hurts the dev cycle a bit.
4 months ago
hello, would you mind if i shared the build table here so we can talk about it, I'm seeing a lot of room for improvements
4 months ago
the table at the top of the build logs
4 months ago
╔══════════════════════════════ Nixpacks v1.31.0 ══════════════════════════════╗
║ setup │ nodejs, libreoffice, qpdf, libnss3, libatk1.0-0, libatk- ║
║ │ bridge2.0-0, libcups2, libgbm1, libasound2, libpangocairo-1.0- ║
║ │ 0, libxss1, libgtk-3-0, libxshmfence1, libglu1 ║
║──────────────────────────────────────────────────────────────────────────────║
║ install │ npm install -g corepack@0.24.1 && corepack enable ║
║ │ pnpm i --frozen-lockfile ║
║──────────────────────────────────────────────────────────────────────────────║
║ build │ echo "Looking for soffice..." && find / -name soffice ║
║ │ 2>/dev/null && echo "Soffice search complete." && corepack ║
║ │ enable && corepack prepare pnpm@8.15.1 --activate && pnpm ║
║ │ install && cd packages && cd common && pnpm build && cd .. && ║
║ │ cd jobs && pnpm build && cd .. && cd ai && pnpm build && cd .. ║
║ │ && if [ "$NODE_ENV" = "development" ]; then echo "Skipping ║
║ │ builds in development mode"; else if [ "$RAILWAY_SERVICE" = ║
║ │ "dashboard" ]; then cd dashboard && pnpm build; elif [ ║
║ │ "$RAILWAY_SERVICE" = "jobs" ]; then echo "jobs package already ║
║ │ built"; elif [ "$RAILWAY_SERVICE" = "api" ]; then cd api && ║
║ │ pnpm build; fi; fi ║
║ │ ║
║──────────────────────────────────────────────────────────────────────────────║
║ start │ cd packages/$RAILWAY_SERVICE && pnpm start ║
╚══════════════════════════════════════════════════════════════════════════════╝
i see a couple spots where the build takes many seconds, esp at the end. but also the deploy step after build takes about 2 mins
is that just because the codebase has gotten to be sprawling? (node_modules is huge now?)
4 months ago
i dont think your svelte app needs libreoffice and all of its deps?
you are enabling corepack twice, once in the install, and again in the build phase
your install command is installing all deps for all packages, you can likely get away with only installing the deps needed for the svelte app.
you are running install twice, once during the install phase, and again in the build phase.
its a tell tale sign if you are using
cd
in any phase, something is being done wrong, you should be using the --filter flag for pnpm instead
4 months ago
im sure theres more, but thats what sticks out to me
THANK YOU!
my svelte app doesnt need libreoffice, but my backend does. it's a monorepo. i'll think about how i can improve this so it's not installed in the frontend's container
which stage should i be using to enable corepack, install or build?
monorepo-- not sure if can just install minimums for svelte app, but will play around here
good catch!
blame AI 🙂
I'll look at all these suggestions.
But would you say all this affects the deploy time after the build as well? (maybe because libre is huge? idk)
4 months ago
maybe netlify is doing cache on your builds while Railway doesn't most of the times
4 months ago
do you have a nixpacks.toml file with those deps defined? you could create a svelte specific nixpacks.toml file that doesnt include that stuff.
yep, install only.
maybe, im not sure if your svelte app will rely on built files from other packages.
🙂
fair
But would you say all this affects the deploy time after the build as well? (maybe because libre is huge? idk)
oh yes for sure, a lot is happening that doesnt need to, you could likely even get your build times down even further with a custom dockerfile since then you could really tweak every bit of how the build is done.
4 months ago
we somewhat fixed this 🙂
still not perfect though, cache is per builder instead of being central, and builders cycle, you can land on a different builer, etc
there's no silver bullet here, i think is your takeaway @brody
i've clearly just got to bear down and redo everything with my own docker, feels like, vs battling with nixpacks. then i can test it faster locally to ensure that the docker build phases are quick. agree?
4 months ago
you could definitely do all you need to with a nixpacks.toml file, but I personally would do with a Dockerfile, yeah
4 months ago
a dockerfile for each package
4 months ago
and dont use cd
lol
do you guys have any example projects i could reference on how to set up the dockerfile within railway?
4 months ago
Just have a svelte.Dockerfile
in your repo and set a RAILWAY_DOCKERFILE_PATH=svelte.Dockerfile
variable
4 months ago
!s
Status changed to Solved brody • 4 months ago