Is it possible to download the docker image from a running railway app?

Hey, I need to download the docker image or at least the sql file inside it Would it be possible to stop the server, add a on deploy command to download the sql file on my computer snd redeploy it? The issue is that the sql file isn't the same as the one on my repo so I don't know if stopping the server and running it again would restore the sql file to it's git hub version
40 Replies
Percy
Percy3y ago
Project ID: 866079ee-0ce9-4a7d-8282-2e56ee9e6849
MadeInShineA
MadeInShineAOP3y ago
866079ee-0ce9-4a7d-8282-2e56ee9e6849
Finn
Finn3y ago
Please don't duplicate posts it looks like both your posts are about the same issue
MadeInShineA
MadeInShineAOP3y ago
Sorry Would it be possible to keep a file in the docker when rebuilding? It could also fix the issue since it wouldn't erase the db with the github one
jackson
jackson3y ago
why not host a proper postgres DB on railway? that way the data would persist, and then you could just access the data from your computer locally easily
Finn
Finn3y ago
no
MadeInShineA
MadeInShineAOP3y ago
It takes to much time to make requests and so makes my app crash
jackson
jackson3y ago
too much time? what do you mean by that unless the latency was >1s or something it shouldn't just crater
MadeInShineA
MadeInShineAOP3y ago
When I used the railway postgress database, my app crashed no matter what timeout I gave to the workers
jackson
jackson3y ago
that sounds more like a misconfiguration with the connection details than a latency issue
MadeInShineA
MadeInShineAOP3y ago
The workaround I found was to then use a sqlite file instead
jackson
jackson3y ago
is this a django webapp by any chance?
MadeInShineA
MadeInShineAOP3y ago
It is
jackson
jackson3y ago
ah so you're using a sqlite3 db
MadeInShineA
MadeInShineAOP3y ago
Yes
jackson
jackson3y ago
yeah i've used django + railway's postgres, it works fine ime just need to make sure the connection details are correct + the driver is set properly
MadeInShineA
MadeInShineAOP3y ago
The database worked fine It just took too much time So atm I'm stuck with a sqlite file being updated inside the railway docker...
jackson
jackson3y ago
hmmm yeah i did notice significantly higher latency vs something on the same subnet on a service like fly or aws and since django makes a lot of db queries a slight increase in latency makes the perceived latency on your end a lot worse
MadeInShineA
MadeInShineAOP3y ago
And so every time I push to my gh repo it resets the db... So I'm softlocked
jackson
jackson3y ago
yeaaaaaaaaaaaaa hmmm if you really want a better db experience i'd recommend a more network-optimized provider like fly.io, very similar in policy and setup to railway, uses nixpacks, etc etc it's a little more complicated setup wise, their UX is not as smooth as railway for the non-experienced but the DB latencies are way better railway is also working on better private networking iirc but im not sure of the timeline there as kinda a last resort workaround you could make some sort of page in your admin panel that uploads the sqlite to gdrive or something but that sounds kinda sketchy and 1 wrong step and all ur data gone anguish
MadeInShineA
MadeInShineAOP3y ago
I can't update my Django admin page since that would mean pushing to gh... 😦 And so reseting the database...
jackson
jackson3y ago
anguish catch-22 regardless if you want to access the container you'll need to install tailscale or something in it which will require a redeploy/reset
MadeInShineA
MadeInShineAOP3y ago
If redeploy doesn't reset the files from the Gh I could maybe add a Deploy command to download the file or something? That's very tricky tho
jackson
jackson3y ago
if you make an entrypoint.sh call in the dockerfile (if you're using one), you can download it there pre-django start i.e. the dockerfile ends with
CMD ['entrypoint.sh']
CMD ['entrypoint.sh']
and you have a shell script in ur repo that looks like
wget -o my_app/db.sqlite3 https://somwhere.com/ur_db
python manage.py runserver #or gunicorn/nginx if u use those
wget -o my_app/db.sqlite3 https://somwhere.com/ur_db
python manage.py runserver #or gunicorn/nginx if u use those
MadeInShineA
MadeInShineAOP3y ago
I don't think I have a docker file inside my Django app
Finn
Finn3y ago
The database you were hosting was it in the same region as your sever?
jackson
jackson3y ago
it's a sqlite3 flatfile but it would have been if they were both on the same railway project right?
MadeInShineA
MadeInShineAOP3y ago
The postgress one? I don't know, I'm from Eu
Finn
Finn3y ago
Nah the normal dB he had Whatever dB you chose make sure it's hosted in the usa Otherwise your dB will be on the others side of the plannet
jackson
jackson3y ago
ah yeah, if it's not in railway make sure it's in us-west that's where railway is based iirc EU regions soon™️
MadeInShineA
MadeInShineAOP3y ago
I had the railway postgress one So us hosted I guess That would explain the delay
jackson
jackson3y ago
indeed
MadeInShineA
MadeInShineAOP3y ago
😦
jackson
jackson3y ago
yeah sorry about that, i don't think there's a super easy fix, if you want persistence you'll have to either - make some super hacky/unstable workaround (probably not a good idea) - switch to a postgres db hosted on railway (more latency) - switch to a hosted db with another provider closer to where you live (more $$$)
MadeInShineA
MadeInShineAOP3y ago
And all of that would make me lose the db
jackson
jackson3y ago
correct i dont think it will be possible to export/backup the db at this point, the container is isolated and you can't ssh in
MadeInShineA
MadeInShineAOP3y ago
😭☠️ Maybe a Railway dev could access it and so literally save my life
Finn
Finn3y ago
Spoiler they can't
MadeInShineA
MadeInShineAOP3y ago
Idk if I understand it properly but wouldn't this allow me to access my running docker files? https://docs.railway.app/develop/cli#local-shell
Railway Docs
CLI | Railway Docs
Documentation for Railway
MadeInShineA
MadeInShineAOP3y ago
Nvm...
Want results from more Discord servers?
Add your server