R
Railway•8mo ago
cybershizo

How to deploy geoipdate on Railway?

geoipupdate is a program that allows you to get a local copy of an IP database so you can inspect a IP address and get a rough idea of where your users are coming from. It's like a free version of the IP API services
54 Replies
Percy
Percy•8mo ago
Project ID: N/A
cybershizo
cybershizoOP•8mo ago
Updating GeoIP and GeoLite Databases
Develop applications using industry-leading IP intelligence and risk scoring.
cybershizo
cybershizoOP•8mo ago
GitHub
Releases · maxmind/geoipupdate
GeoIP update client code. Contribute to maxmind/geoipupdate development by creating an account on GitHub.
cybershizo
cybershizoOP•8mo ago
It looks like I have possibly several options Use dedicated Docker thing Get binary from GitHub Use Nix package How would you got about figuring out which methodology to pursue? My impression is that if geoipupdate is supposed to be a long lived service, you would want to install it on a service in a way that doesn't reinstall it everytime meaning it's a part of the deploy, so that could mean Nix or Docker
Brody
Brody•8mo ago
why not just run an in code cron job to check for updates and download if needed, storing the database in a volume
cybershizo
cybershizoOP•8mo ago
I did that yesterday, it's a ton of boilerplate and geoipupdate is implemented in Go the same language I wrote my thing in I figured I'd try the prescribed solution instead of reinvent the wheel But I'm pretty confused about using Nix or Docker, It seems like Nix is supposed to be easier but it just seems more convoluted to me
Brody
Brody•8mo ago
so geoipupdate the binary is a long lived process and just downloads the database and any updates when it comes out?
cybershizo
cybershizoOP•8mo ago
Yes The website doesn't state when the database updates to geoipupdate would probably just handle all the ambiguity for you
Brody
Brody•8mo ago
so you need a way to run that in parallel with your go app?
cybershizo
cybershizoOP•8mo ago
Yeah it comes with a conf file for cron So I guess what I'm asking is they distribute both a binary in GitHub and a Docker But I can't SSH into a service right?
Brody
Brody•8mo ago
correct is it a long lived process or no?
cybershizo
cybershizoOP•8mo ago
Yes Well actually No if it uses a cron job No it probably isn't
Brody
Brody•8mo ago
yeah exactly
cybershizo
cybershizoOP•8mo ago
My point was that it's supposed to live in a VM that doesn't get shutdown because it has it's own cron job Not supposed to be an ephemeral serverless thing So if there's a binary on GitHub should I just download the right the architecture and commit it to git so it shows up in the Railway VM or Docker copy it or something else you think? If I could SSH into Railway I could set it up once but that doesn't seem to be available
Brody
Brody•8mo ago
even if you could ssh into the service and set it up, it wont not be setup next time you deploy
cybershizo
cybershizoOP•8mo ago
I also don't know how I'd know which binary to select from assuming it's Linux
geoipupdate_6.1.0_linux_386.deb
2.09 MB
Jan 9
geoipupdate_6.1.0_linux_386.rpm
2.16 MB
Jan 9
geoipupdate_6.1.0_linux_386.tar.gz
2.09 MB
Jan 9
geoipupdate_6.1.0_linux_amd64.deb
2.21 MB
Jan 9
geoipupdate_6.1.0_linux_amd64.rpm
2.28 MB
Jan 9
geoipupdate_6.1.0_linux_amd64.tar.gz
2.2 MB
Jan 9
geoipupdate_6.1.0_linux_arm64.deb
2.04 MB
Jan 9
geoipupdate_6.1.0_linux_arm64.rpm
2.09 MB
Jan 9
geoipupdate_6.1.0_linux_arm64.tar.gz
2.03 MB
Jan 9
geoipupdate_6.1.0_linux_armv6.deb
2.09 MB
Jan 9
geoipupdate_6.1.0_linux_armv6.rpm
2.14 MB
Jan 9
geoipupdate_6.1.0_linux_armv6.tar.gz
geoipupdate_6.1.0_linux_386.deb
2.09 MB
Jan 9
geoipupdate_6.1.0_linux_386.rpm
2.16 MB
Jan 9
geoipupdate_6.1.0_linux_386.tar.gz
2.09 MB
Jan 9
geoipupdate_6.1.0_linux_amd64.deb
2.21 MB
Jan 9
geoipupdate_6.1.0_linux_amd64.rpm
2.28 MB
Jan 9
geoipupdate_6.1.0_linux_amd64.tar.gz
2.2 MB
Jan 9
geoipupdate_6.1.0_linux_arm64.deb
2.04 MB
Jan 9
geoipupdate_6.1.0_linux_arm64.rpm
2.09 MB
Jan 9
geoipupdate_6.1.0_linux_arm64.tar.gz
2.03 MB
Jan 9
geoipupdate_6.1.0_linux_armv6.deb
2.09 MB
Jan 9
geoipupdate_6.1.0_linux_armv6.rpm
2.14 MB
Jan 9
geoipupdate_6.1.0_linux_armv6.tar.gz
Right
Brody
Brody•8mo ago
are you using nixpacks?
cybershizo
cybershizoOP•8mo ago
I have. I can
Brody
Brody•8mo ago
are you using nixpacks in this app of yours?
cybershizo
cybershizoOP•8mo ago
I can, this is a standalone service, it can use whatever This is meant to be a microservice so I can ping users IP and store it in their session info. First step is getting the db stuff under control the rest is easy If I use Nix I assume I just list it as a dependency like ["go", "geoipupdate"] and theoretically it is in my path or something? I am skiddish on Nix because if I changed providers with me I can't assume Nix will work somewhere else So having the binary download on initialization or just using Docker seems to make more sense
Brody
Brody•8mo ago
you would want to do array extending ['...', 'geoipupdate'] dont specify go since that would be added by railway automatically use a Dockerfile then
cybershizo
cybershizoOP•8mo ago
As far as the conf for the cron job it gives you I just hope I put it in the right place and the VM picks it up? It almost seems easier to reinvent the wheel here Sorry for all the questions, deployments are not my strength
Brody
Brody•8mo ago
not how it works, you would have to install cron into the container and load the config file, and then finally start the cron daemon also they arent really VMs they are containers
cybershizo
cybershizoOP•8mo ago
So I shouldn't assume cron just works In that case it sounds like I should just stick with my hand rolled code
Brody
Brody•8mo ago
you really shouldnt assume anything will just work
cybershizo
cybershizoOP•8mo ago
I know lmao OK but assuming I went with the binary, is there a way to know what platform specifically to use? I could probably write a Go program that will run a command and just tell me the answer, assuming that architectures don't change between deployments?
Brody
Brody•8mo ago
linux_amd64
cybershizo
cybershizoOP•8mo ago
Ah
Brody
Brody•8mo ago
it wont ever be anything but that
cybershizo
cybershizoOP•8mo ago
OK thanks, so basically I download the binary and then I can invoke it manually or use Railway's cron settings Was I misunderstanding the thing about cron in Railway? From the other thread
Brody
Brody•8mo ago
well in this case it would need to be done in the same service that you run your api in so you cant use railway cron for web services aka this needs to be an in code cron or linux cron
cybershizo
cybershizoOP•8mo ago
Well my plan was to back up the DB to R2 That part is pretty easy
Brody
Brody•8mo ago
but honestly even though its a lot of boilerplate, a fully in code solution is not a bad idea
cybershizo
cybershizoOP•8mo ago
So once serivce for syncing DBs and one service for reading IPs Yeah, I feel that
Brody
Brody•8mo ago
thats just going to cost you extra in egress fees
cybershizo
cybershizoOP•8mo ago
R2 egress is free The dbs are pretty small
Brody
Brody•8mo ago
railway is not
cybershizo
cybershizoOP•8mo ago
Oh right But still I don't think 50mb twice a week is a lot?
Brody
Brody•8mo ago
no but theres really no need
cybershizo
cybershizoOP•8mo ago
What would you do? Given the same problem
Brody
Brody•8mo ago
store the database on a volume in the same service as the api
cybershizo
cybershizoOP•8mo ago
So two services one VM with a volume? Or collapse into one service with a volume?
Brody
Brody•8mo ago
not VMs, container* but yes your api would be responsible for doing its own thing and downloading the database
cybershizo
cybershizoOP•8mo ago
OK I can try that, I've never used volumes intentionally before :salute:
Brody
Brody•8mo ago
its just a path and then you store the files in the path
cybershizo
cybershizoOP•8mo ago
But can you debug it? Like in Railway is there anyway to LS it? How are you supposed to know what the contents are, does the web view help you?
Brody
Brody•8mo ago
there is not any native way to do that
cybershizo
cybershizoOP•8mo ago
Sounds related to https://discord.com/channels/713503345364697088/1225968032631754802 OK but it's a volume that you can programmatically LS is your point
Brody
Brody•8mo ago
you know the contents because you wrote the code that put the files into the volume i mean you can do it via code yes, but you are storing one file in a single location, you cant mess that up
cybershizo
cybershizoOP•8mo ago
Don't underestimate my naiveness 🙂
Brody
Brody•8mo ago
haha dont overthink it
cybershizo
cybershizoOP•8mo ago
Alright, thanks!
Brody
Brody•8mo ago
no problem!
Want results from more Discord servers?
Add your server