Proposal for Install Dgraph section of Readme.md

My idea is to enable everyone to use DGraph, to make DGraph as a default choice of database for application developers to build their mobile/web applications. One of the very significant steps needed to get there is to make setting up of Dgraph super simple and really easy, It should be made so simple that anyone can now, for the first time in history, should be able to have a GraphDB up running and ready to use in less than a minute.

In this regard here my propsal for the Install section of the Readme.md. That needs DGraph to offer binary releases ( One of advantages of DGraph being build in Go, need not ask users to install complicated libraries, just a binary would suffice! ).

Install and run DGraph

 $ chmod +x dgraph
 $ ./dgraph --mutations ~/dgraph/m --postings ~/dgraph/p --uids ~/dgraph/

Note: Explore dgraph --help for more options

 $ chmod +x dgraph
 $ ./dgraph --mutations ~/dgraph/m --postings ~/dgraph/p --uids ~/dgraph/
  • Docker
$ docker pull dgraph/dgraph:latest
# Setting a somedir volume on the host will persist your data.
$ docker run -t -i -v /somedir:/dgraph -p 80:8080 dgraph/dgraph:latest
# Ensure mutations directory exists.
$ mkdir /dgraph/m
# Run the server
$ dgraph --mutations /dgraph/m --postings /dgraph/p --uids /dgraph/u
  • From Source

NOTE: Source installation is intended for only developers and advanced users. For general use, please download official releases from https://download.dgraph.io/.

If you do not have a working Golang environment, please install Go 1.6 from here.

$ go get -d github.com/dgraph-io/dgraph
# Make file takes care of installing RocksDB dependency too. 
$ make
$ $GOPATH/bin/dgraph --mutations /dgraph/m --postings /dgraph/p --uids /dgraph/u

@hackintoshrao: This looks really good. I think @ashwin95r has a task to look into building binaries for Dgraph. If you’re interested, talk to him and see if you want to pick it up.

1 Like

Sure, will coordinate with @ashwin95r on this.

@mrjn: Also the pending proposal of running Dgraph with default arguments will help immensely.

Yeah, I think we’re close to a resolution here:

That looks great, That’ll make usage more simple :slight_smile:

Doing a direct go build . gives a dynamically linked executable which depends on librocksdb and doesnt run on machines which do not have rocksDB installed. I’m working on creating a statically linked binary and let’s see if it works out. go build --ldflags '-extldflags "-static"' .

1 Like

That’ll be great … Will be really helpful for binary releases. Any timeline on the binary release plan?

We could do it as soon as we have a working binary or along with the v0.4 release. What do you suggest @mrjn, @hackintoshrao ?

It’ll great to have it soon. But yes, there might be lot on the road for you guys. I’ll work on building a static binary meanwhile and see how it goes.

I’m already working on it. Should be done in sometime @hackintoshrao. You could test it out too :slight_smile:

@ashwin95r: Ah, cool. Sure :slight_smile:

@ashwin95r: Also it’ll be nice if you could document and share how its built.

I statically compiled the dgraphassigner and I’ll share the binary in slack. This would be the command to build any binary statically : go build --ldflags '-extldflags "-static"' .

Sure, As I mentioned, a small note on how you built would be helpful to create scripts for doing so.

1 Like

So, if we’re now able to build static binaries, let’s do two things:

  • Create the Makefile as proposed by @hackintoshrao
  • Switch to Alpine Linux Docker image as suggested by @compton
2 Likes

I’m still not able to compile the server statically

# github.com/dgraph-io/dgraph/dgraph
/usr/local/go/pkg/tool/linux_amd64/link: running gcc failed: exit status 1
/tmp/go-link-159525422/000000.o: In function `_cgo_29becdab8e08_C2func_getaddrinfo':
/tmp/workdir/go/src/net/cgo_unix.go:57: warning: Using 'getaddrinfo' in statically linked applications requires at runtime the shared libraries from t
he glibc version used for linking

Looks like we need to switch from glibc to musl gcc or find some other way to tackle this. Once that is done we could have independent binaries.

I will create issues on Github for the same under the section help_wanted for these then.

I feel we should handle this. If someone has already done this, then okay, but otherwise this doesn’t seem very straightforward.

Sorry, I was talking about[quote=“mrjn, post:16, topic:372”]
Create the Makefile as proposed by @hackintoshrao

Switch to Alpine Linux Docker image as suggested by @compton
[/quote]