Runing a dgraph database on fly.io

Is it possible to run a database like dgraph on fly.io? Their guide looks simple, but i don’t know how to do the networking part.

It all boils down to configuring 2 fly apps based on these commands below, which is easy,

App 1:

docker run -it -p 5080:5080 --network dgraph_default -p 6080:6080 -v ~/zero:/dgraph dgraph/dgraph:v21.12.0 dgraph zero --my=$ZERO_IP_ADDRESS:5080

App 2:

docker run -it -p 7080:7080 --network dgraph_default -p 8080:8080 -p 9080:9080 -v ~/server1:/dgraph dgraph/dgraph:v21.12.0 dgraph alpha --zero=$ZERO_IP_ADDRESS:5080 --my=$ALPHA_IP_ADDRESS:7080

But what I don’t know how to do is figuring out the $ZERO_IP_ADDRESS and $ALPHA_IP_ADDRESS at run time.

Any ideas?

What do those two IP address settings do?

If you need the local private IPv6 address you can do some shell script like this:

ip=$(grep fly-local-6pn /etc/hosts | cut -f 1)

If you need another app’s private IP, it’s simplest to just use <app-name>.internal. If dgraph won’t resolve that for some reason, you can do your own DNS lookup with a similar shell script.