R
Railway•14mo ago
GetPsyched

Trying to generate files before runtime

I recently pushed a commit in my project that adds some auto generated files to .gitignore. But this broke Railway trying to deploy my app because I don't have those files anymore. The files in question can be generated by a simple command: sqlc generate. Though I tried putting this as the build command and start commands but nothing seems to work. Note: I don't want to use a Dockerfile for something as trivial as this.
Solution:
install it from nixpacks on railway too? nixpacks.toml ```toml [phases.setup]...
Jump to solution
39 Replies
Percy
Percy•14mo ago
Project ID: 69531a0b-78b7-4a71-9df4-3a8db9703b69
GetPsyched
GetPsyched•14mo ago
service: breadboard
Brody
Brody•14mo ago
thats not a uuidv4
GetPsyched
GetPsyched•14mo ago
what Oh Service: 20823280-db07-46f3-b4a3-1809ce497302 I thought y'all could see names my bad
Brody
Brody•14mo ago
i cant see anything
GetPsyched
GetPsyched•14mo ago
well, do you know how I can tell Railway to download SQLC and run the command?
Brody
Brody•14mo ago
what language?
GetPsyched
GetPsyched•14mo ago
Go SQLC is a standalone dependency that converts SQL queries into any supported language's functions
Brody
Brody•14mo ago
how did you read my mind
GetPsyched
GetPsyched•14mo ago
lol
Brody
Brody•14mo ago
how would you install sqlc locally?
GetPsyched
GetPsyched•14mo ago
Well, from my package manager
Brody
Brody•14mo ago
what is your package manager
GetPsyched
GetPsyched•14mo ago
Nix I had also used pacman for sqlc back when I used Manjaro Oh seems like it can be installed using go install or go get Ref: https://docs.sqlc.dev/en/stable/overview/install.html
Solution
Brody
Brody•14mo ago
install it from nixpacks on railway too? nixpacks.toml
[phases.setup]
nixPkgs = ['...', 'sqlc']

[phases.sqlc]
dependsOn = ['setup']
cmds = ['sqlc generate']
[phases.setup]
nixPkgs = ['...', 'sqlc']

[phases.sqlc]
dependsOn = ['setup']
cmds = ['sqlc generate']
GetPsyched
GetPsyched•14mo ago
That's a nice toml file but I don't want to couple my codebase with hosting paincloud mean I'll do it if it's the last option I have It's defined in my flake.nix but sadly no support yet 2 of my other services broke because of the changes here 💀
Brody
Brody•14mo ago
thats the only way i can think of broke because of the recent nixpacks update?
GetPsyched
GetPsyched•14mo ago
Can I add it to my go.mod so that it will automatically be downloaded and then set my start command as sqlc generate && go run cmd.main.go? No, because I made breaking changes to the database and the newer version of my service supports it but that's crashing because of this error
Brody
Brody•14mo ago
i can not recommend that method, i can also not recommend you use go run in a production environment
GetPsyched
GetPsyched•14mo ago
Why is it not recommended? Also alternative to go run? go build?
Brody
Brody•14mo ago
respectfully, its a hacky solution railway builds your go app and then runs the resulting binary, this is the preferred way to run a go app in a production environment
GetPsyched
GetPsyched•14mo ago
Yeah, makes sense. Yeah. I just said go run as in anything that's used to run a prod environment setup. Not specifically run Can I expect flake support in the coming months?
Brody
Brody•14mo ago
unlikely tbh
GetPsyched
GetPsyched•14mo ago
Until then I can afford to just manually do railway up with temporarily removing the needed files from gitignore Damn, rip
Brody
Brody•14mo ago
you are that opposed to putting a file in your repo? i cant understand that if im being honest
GetPsyched
GetPsyched•14mo ago
Oh right I forgot about that option I mean I'm not that opposed It's just I like to stick to some coding principles The principle here being no coupling: Hosting quirks should stay away from the codebase Though I plan to stay with Railway for a long time, I don't want vendor lock-in
Brody
Brody•14mo ago
i mean how would you tell fly to do this?
GetPsyched
GetPsyched•14mo ago
fly? I can remove the dots there, right?
Brody
Brody•14mo ago
no shot you dont know what fly is?
GetPsyched
GetPsyched•14mo ago
I'm guessing they're just a placeholder
Brody
Brody•14mo ago
no
GetPsyched
GetPsyched•14mo ago
no? is it like a hosting platform
Brody
Brody•14mo ago
i didnt know it was possible to know about railway without knowing about fly
GetPsyched
GetPsyched•14mo ago
Can't find anything in my SE because of the generic name What is it lol
Brody
Brody•14mo ago
same thing as railway
GetPsyched
GetPsyched•14mo ago
I see
Brody
Brody•14mo ago
either way the nixpacks.toml is the way to go
GetPsyched
GetPsyched•14mo ago
the toml worked btw
Brody
Brody•14mo ago
awsome
Want results from more Discord servers?
Add your server