Upload large file via CLI

Hi there, I have two 200mb files that are ignored by git. I want to upload to the railway instance. How do I do that so I can deploy? Thanks
Solution:
for context, this was solved with a custom dockerfile and fixing a lot of dependency conflicts
Jump to solution
59 Replies
Percy
Percy•13mo ago
Project ID: N/A
arandomfellanamedmike
arandomfellanamedmike•13mo ago
service_id: 92e27f59-0420-4bb1-aa1f-625ef3e927f3
Brody
Brody•13mo ago
the cli upload limit is something like 50mb, and railway doesn't support git lfs (your 200mb files would be in git lfs) the best way for you to go about this would be to have code to download the files from a storage bucket
arandomfellanamedmike
arandomfellanamedmike•13mo ago
How would I do that exactly? These are files which are used in conjunction with a module...they have to be put in a specific spot in the file system even locally
Brody
Brody•13mo ago
write code to download the files from a storage bucket to the needed location
arandomfellanamedmike
arandomfellanamedmike•13mo ago
Well haha thank you sorry I'm not too well versed in this stuff I mean is this a script that runs on build? If so, how would I do that?
Brody
Brody•13mo ago
run in build or before start, whatever is easiest for you
arandomfellanamedmike
arandomfellanamedmike•13mo ago
I appreciate the patience
Brody
Brody•13mo ago
you would need to add another phase to run your code that downloads the file https://nixpacks.com/docs/configuration/file#phases
arandomfellanamedmike
arandomfellanamedmike•13mo ago
Will give it a shot thanks 🫡
Brody
Brody•13mo ago
no problem!
arandomfellanamedmike
arandomfellanamedmike•13mo ago
Hey so my script relies on a package that needs to be downloaded So I get an error thrown when I run it with this nix.toml: [phases.setup] nixPkgs = ["...", "tesseract"] [phases.downloadModules] cmds = ["python downloadModules.py"] The second phase is what is impt
angelo
angelo•13mo ago
Whats the usecase you are trying to solve here?
arandomfellanamedmike
arandomfellanamedmike•13mo ago
200mb file needs to be downloaded to root directory for use with a module I'm storing in a bucket Want to download from bucket I need to do it at build time...it's a chromium module for dealing with PDFs The error that gets thrown is a module not found:#10 0.418 ModuleNotFoundError: No module named 'supabase' Which I think just means the phase needs to run after packages are installed
Brody
Brody•13mo ago
then you might need a dependsOn = ['install'] in your download phase just so that the download phase is ran after the install phase
arandomfellanamedmike
arandomfellanamedmike•13mo ago
Will try: [phases.setup] nixPkgs = ["...", "tesseract"] [phases.downloadModules] dependsOn = ['install'] cmds = ["python3 -m pip install apryse-sdk --extra-index-url=https://pypi.apryse.com", "python downloadModules.py"]
Brody
Brody•13mo ago
nah that looks hacky put that pip package in your requirements.txt file
arandomfellanamedmike
arandomfellanamedmike•13mo ago
ooof The extra index thing causes errors
Brody
Brody•13mo ago
why is it needed?
arandomfellanamedmike
arandomfellanamedmike•13mo ago
Not sure lol. I think they switched package names or something but are enterprise software so maybe it's for legacy stuff. Support said to make sure it's there Technically this deployed. Lemme see if it runs
Brody
Brody•13mo ago
if it really does need to be there, and it won't work in the requirements.txt file, just extend the install phase cmds array with that command
[phases.install]
cmds = ["...", "your extra install command here"]
[phases.install]
cmds = ["...", "your extra install command here"]
arandomfellanamedmike
arandomfellanamedmike•13mo ago
Gotcha. Will do. There's one more command that needs to be added to get this run so will check that. Thx 🤞
Brody
Brody•13mo ago
you're learning fast, you got this for sure
arandomfellanamedmike
arandomfellanamedmike•13mo ago
Okay so that works...kinda: Exception: ./html2pdf_chromium.so: error while loading shared libraries: libnss3.so: cannot open shared object file: No such file or directory Exit code: 0X7F Some weird shared library issue. Not gonna make you debug this with me LOL but libnss3 is an apt thing, ya?
Brody
Brody•13mo ago
one sec you will need to add these packages to your nixPkgs array
libnss3
libatk1.0-0
libatk-bridge2.0-0
libcups2
libgbm1
libasound2
libpangocairo-1.0-0
libxss1
libgtk-3-0
libnss3
libatk1.0-0
libatk-bridge2.0-0
libcups2
libgbm1
libasound2
libpangocairo-1.0-0
libxss1
libgtk-3-0
remember, 99% of the time, make sure you are extending the arrays, you've already shown that you have done that for nixPkgs so this is just a reminder
arandomfellanamedmike
arandomfellanamedmike•13mo ago
Gotcha and yep will give it a shot rn Hoping this is the one man
Brody
Brody•13mo ago
it might be, fingers crossed
arandomfellanamedmike
arandomfellanamedmike•13mo ago
Hmm not liking those packages
Brody
Brody•13mo ago
who? you or nixpacks?
arandomfellanamedmike
arandomfellanamedmike•13mo ago
haha nixpacks. The third one errors
Brody
Brody•13mo ago
please hold
arandomfellanamedmike
arandomfellanamedmike•13mo ago
Sounds good. Where'd ya get that list btw ? just curious
Brody
Brody•13mo ago
that was from a github issue on nixpacks, I'm going to look at the current librarys nixpacks installs though
arandomfellanamedmike
arandomfellanamedmike•13mo ago
kk. Yeah actually I justed tried the first one [phases.setup] nixPkgs = ["...", "tesseract", "libnss3"] and it failed
Brody
Brody•13mo ago
it's for node, but these are the packages nixpacks installs for puppeteer, and I'm assuming you're using the python equivalent, so it would likely need all the same packages https://github.com/railwayapp/nixpacks/blob/main/src/providers/node/mod.rs#L119
arandomfellanamedmike
arandomfellanamedmike•13mo ago
Ah I see Yeah hmm I wonder why libnss3 is undefined
Brody
Brody•13mo ago
show me the error?
arandomfellanamedmike
arandomfellanamedmike•13mo ago
error: undefined variable 'libnss3'
arandomfellanamedmike
arandomfellanamedmike•13mo ago
GitHub
Install libnss when puppeteer is used · Issue #294 · railwayapp...
We need to install libnss via apt. It is probably worth overhauling the current solution to check if packages are installed and make one-function, purpose-built for this.
Brody
Brody•13mo ago
screenshot of error please
arandomfellanamedmike
arandomfellanamedmike•13mo ago
Oh duh haha that's just a pointer to what you sent
arandomfellanamedmike
arandomfellanamedmike•13mo ago
Brody
Brody•13mo ago
send your full nixpacks.toml please
arandomfellanamedmike
arandomfellanamedmike•13mo ago
At that time it was this: [phases.install] cmds = ["...", "python3 -m pip install apryse-sdk --extra-index-url=https://pypi.apryse.com"] [phases.setup] nixPkgs = ["...", "tesseract", "libnss3"] [phases.downloadModules] dependsOn = ['install'] cmds = ["python downloadModules.py", "chmod +x /app/html2pdf_chromium.so"] Same error happens when doing the full list of packages too
Brody
Brody•13mo ago
show me the nixpacks.toml will all the packages please
arandomfellanamedmike
arandomfellanamedmike•13mo ago
[phases.install] cmds = ["...", "python3 -m pip install apryse-sdk --extra-index-url=https://pypi.apryse.com"] [phases.setup] nixPkgs = ["...", "tesseract", "libnss3", "libatk1.0-0", "libatk-bridge2.0-0", "libcups2","libgbm1","libasound2","libpangocairo-1.0-0","libxss1","libgtk-3-0"] [phases.downloadModules] dependsOn = ['install'] cmds = ["python downloadModules.py", "chmod +x /app/html2pdf_chromium.so"]
Brody
Brody•13mo ago
and you get this error with the nixpacks.toml you just sent
arandomfellanamedmike
arandomfellanamedmike•13mo ago
Sorry let me clear. The error I sent was for the single. This is the error for that one (just ran again). I assume it's bc parses the names first for exceptions
arandomfellanamedmike
arandomfellanamedmike•13mo ago
Sorry for miscommunication
Brody
Brody•13mo ago
in that build error it looks like you just haven't quoted the packages
arandomfellanamedmike
arandomfellanamedmike•13mo ago
I did. I think it just logs it like that?
Brody
Brody•13mo ago
you know, there's always the option of a dockerfile based build?
arandomfellanamedmike
arandomfellanamedmike•13mo ago
Yeah...i just don't know how to do that haha would it be any different tho? Same installations right?
Brody
Brody•13mo ago
quite different, yeah could you share your repo so I can get a better idea of what's going on, that will help me create a dockerfile for you
arandomfellanamedmike
arandomfellanamedmike•13mo ago
Uh yeah that's fine. What's your github?
Brody
Brody•13mo ago
brody192
arandomfellanamedmike
arandomfellanamedmike•13mo ago
Invited. Gonna DM you so we can discuss more personal things to that repo
Brody
Brody•13mo ago
okay!
Solution
Brody
Brody•13mo ago
for context, this was solved with a custom dockerfile and fixing a lot of dependency conflicts