How to deploy geoipdate on Railway?
zaydek
PROOP

2 years ago

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

93 Replies

zaydek
PROOP

2 years ago


zaydek
PROOP

2 years ago



zaydek
PROOP

2 years ago

It looks like I have possibly several options

Use dedicated Docker thing
Get binary from GitHub
Use Nix package


zaydek
PROOP

2 years ago

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
EMPLOYEE

2 years ago

why not just run an in code cron job to check for updates and download if needed, storing the database in a volume


zaydek
PROOP

2 years 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


zaydek
PROOP

2 years ago

I figured I'd try the prescribed solution instead of reinvent the wheel


zaydek
PROOP

2 years ago

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
EMPLOYEE

2 years ago

so geoipupdate the binary is a long lived process and just downloads the database and any updates when it comes out?


zaydek
PROOP

2 years ago

Yes


zaydek
PROOP

2 years ago

The website doesn't state when the database updates to geoipupdate would probably just handle all the ambiguity for you


brody
EMPLOYEE

2 years ago

so you need a way to run that in parallel with your go app?


zaydek
PROOP

2 years ago

Yeah it comes with a conf file for cron


zaydek
PROOP

2 years ago

So I guess what I'm asking is they distribute both a binary in GitHub and a Docker


zaydek
PROOP

2 years ago

But I can't SSH into a service right?


brody
EMPLOYEE

2 years ago

correct


brody
EMPLOYEE

2 years ago

is it a long lived process or no?


zaydek
PROOP

2 years ago

Yes


zaydek
PROOP

2 years ago

Well actually


zaydek
PROOP

2 years ago

No if it uses a cron job


zaydek
PROOP

2 years ago

No it probably isn't


brody
EMPLOYEE

2 years ago

yeah exactly


zaydek
PROOP

2 years 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


zaydek
PROOP

2 years ago

Not supposed to be an ephemeral serverless thing


zaydek
PROOP

2 years ago

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?


zaydek
PROOP

2 years ago

If I could SSH into Railway I could set it up once but that doesn't seem to be available


brody
EMPLOYEE

2 years ago

even if you could ssh into the service and set it up, it wont not be setup next time you deploy


zaydek
PROOP

2 years ago

I also don't know how I'd know which binary to select from assuming it's Linux


zaydek
PROOP

2 years ago

Right


brody
EMPLOYEE

2 years ago

are you using nixpacks?


zaydek
PROOP

2 years ago

I have. I can


brody
EMPLOYEE

2 years ago

are you using nixpacks in this app of yours?


zaydek
PROOP

2 years ago

I can, this is a standalone service, it can use whatever


zaydek
PROOP

2 years ago

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


zaydek
PROOP

2 years ago

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?


zaydek
PROOP

2 years ago

I am skiddish on Nix because if I changed providers with me I can't assume Nix will work somewhere else


zaydek
PROOP

2 years ago

So having the binary download on initialization or just using Docker seems to make more sense


brody
EMPLOYEE

2 years ago

you would want to do array extending ['...', 'geoipupdate'] dont specify go since that would be added by railway automatically


brody
EMPLOYEE

2 years ago

use a Dockerfile then


zaydek
PROOP

2 years ago

As far as the conf for the cron job it gives you


zaydek
PROOP

2 years ago

I just hope I put it in the right place and the VM picks it up?


zaydek
PROOP

2 years ago

It almost seems easier to reinvent the wheel here


zaydek
PROOP

2 years ago

Sorry for all the questions, deployments are not my strength


brody
EMPLOYEE

2 years 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


brody
EMPLOYEE

2 years ago

also they arent really VMs they are containers


zaydek
PROOP

2 years ago

So I shouldn't assume cron just works


zaydek
PROOP

2 years ago

In that case it sounds like I should just stick with my hand rolled code


brody
EMPLOYEE

2 years ago

you really shouldnt assume anything will just work


zaydek
PROOP

2 years ago

I know lmao


zaydek
PROOP

2 years ago

OK but assuming I went with the binary, is there a way to know what platform specifically to use?


zaydek
PROOP

2 years ago

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
EMPLOYEE

2 years ago

linux_amd64


zaydek
PROOP

2 years ago

Ah


brody
EMPLOYEE

2 years ago

it wont ever be anything but that


zaydek
PROOP

2 years ago

OK thanks, so basically I download the binary and then I can invoke it manually or use Railway's cron settings


zaydek
PROOP

2 years ago

Was I misunderstanding the thing about cron in Railway? From the other thread


brody
EMPLOYEE

2 years ago

well in this case it would need to be done in the same service that you run your api in


brody
EMPLOYEE

2 years ago

so you cant use railway cron for web services


brody
EMPLOYEE

2 years ago

aka this needs to be an in code cron or linux cron


zaydek
PROOP

2 years ago

Well my plan was to back up the DB to R2


zaydek
PROOP

2 years ago

That part is pretty easy


brody
EMPLOYEE

2 years ago

but honestly even though its a lot of boilerplate, a fully in code solution is not a bad idea


zaydek
PROOP

2 years ago

So once serivce for syncing DBs and one service for reading IPs


zaydek
PROOP

2 years ago

Yeah, I feel that


brody
EMPLOYEE

2 years ago

thats just going to cost you extra in egress fees


zaydek
PROOP

2 years ago

R2 egress is free


zaydek
PROOP

2 years ago

The dbs are pretty small


brody
EMPLOYEE

2 years ago

railway is not


zaydek
PROOP

2 years ago

Oh right


zaydek
PROOP

2 years ago

But still I don't think 50mb twice a week is a lot?


brody
EMPLOYEE

2 years ago

no but theres really no need


zaydek
PROOP

2 years ago

What would you do? Given the same problem


brody
EMPLOYEE

2 years ago

store the database on a volume in the same service as the api


zaydek
PROOP

2 years ago

So two services one VM with a volume?


zaydek
PROOP

2 years ago

Or collapse into one service with a volume?


brody
EMPLOYEE

2 years ago

not VMs, container*

but yes your api would be responsible for doing its own thing and downloading the database


zaydek
PROOP

2 years ago

OK I can try that, I've never used volumes intentionally before


zaydek
PROOP

2 years ago

<:salute:1137099685417451530>


brody
EMPLOYEE

2 years ago

its just a path and then you store the files in the path


zaydek
PROOP

2 years ago

But can you debug it?


zaydek
PROOP

2 years ago

Like in Railway is there anyway to LS it?


zaydek
PROOP

2 years ago

How are you supposed to know what the contents are, does the web view help you?


brody
EMPLOYEE

2 years ago

there is not any native way to do that



zaydek
PROOP

2 years ago

OK but it's a volume that you can programmatically LS is your point


brody
EMPLOYEE

2 years ago

you know the contents because you wrote the code that put the files into the volume


brody
EMPLOYEE

2 years ago

i mean you can do it via code yes, but you are storing one file in a single location, you cant mess that up


zaydek
PROOP

2 years ago

Don't underestimate my naiveness


zaydek
PROOP

2 years ago

🙂


brody
EMPLOYEE

2 years ago

haha dont overthink it


zaydek
PROOP

2 years ago

Alright, thanks!


brody
EMPLOYEE

2 years ago

no problem!


Loading...