R
Railway•15mo 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•15mo ago
Project ID: 69531a0b-78b7-4a71-9df4-3a8db9703b69
GetPsyched
GetPsychedOP•15mo ago
service: breadboard
Brody
Brody•15mo ago
thats not a uuidv4
GetPsyched
GetPsychedOP•15mo ago
what Oh Service: 20823280-db07-46f3-b4a3-1809ce497302 I thought y'all could see names my bad
Brody
Brody•15mo ago
i cant see anything
GetPsyched
GetPsychedOP•15mo ago
well, do you know how I can tell Railway to download SQLC and run the command?
Brody
Brody•15mo ago
what language?
GetPsyched
GetPsychedOP•15mo ago
Go SQLC is a standalone dependency that converts SQL queries into any supported language's functions
Brody
Brody•15mo ago
how did you read my mind
GetPsyched
GetPsychedOP•15mo ago
lol
Brody
Brody•15mo ago
how would you install sqlc locally?
GetPsyched
GetPsychedOP•15mo ago
Well, from my package manager
Brody
Brody•15mo ago
what is your package manager
GetPsyched
GetPsychedOP•15mo 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•15mo 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
GetPsychedOP•15mo 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•15mo ago
thats the only way i can think of broke because of the recent nixpacks update?
GetPsyched
GetPsychedOP•15mo 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•15mo ago
i can not recommend that method, i can also not recommend you use go run in a production environment
GetPsyched
GetPsychedOP•15mo ago
Why is it not recommended? Also alternative to go run? go build?
Brody
Brody•15mo 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
GetPsychedOP•15mo 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•15mo ago
unlikely tbh
GetPsyched
GetPsychedOP•15mo ago
Until then I can afford to just manually do railway up with temporarily removing the needed files from gitignore Damn, rip
Brody
Brody•15mo ago
you are that opposed to putting a file in your repo? i cant understand that if im being honest
GetPsyched
GetPsychedOP•15mo 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•15mo ago
i mean how would you tell fly to do this?
GetPsyched
GetPsychedOP•15mo ago
fly? I can remove the dots there, right?
Brody
Brody•15mo ago
no shot you dont know what fly is?
GetPsyched
GetPsychedOP•15mo ago
I'm guessing they're just a placeholder
Brody
Brody•15mo ago
no
GetPsyched
GetPsychedOP•15mo ago
no? is it like a hosting platform
Brody
Brody•15mo ago
i didnt know it was possible to know about railway without knowing about fly
GetPsyched
GetPsychedOP•15mo ago
Can't find anything in my SE because of the generic name What is it lol
Brody
Brody•15mo ago
same thing as railway
GetPsyched
GetPsychedOP•15mo ago
I see
Brody
Brody•15mo ago
either way the nixpacks.toml is the way to go
GetPsyched
GetPsychedOP•15mo ago
the toml worked btw
Brody
Brody•15mo ago
awsome
Want results from more Discord servers?
Add your server