Dgraph compile with CGO_ENABLED=0

when I make dgraph with CGO_ENABLED=0,it failed as below

# github.com/dgraph-io/ristretto/z
../../ristretto/z/allocator.go:84:17: undefined: Calloc
../../ristretto/z/allocator.go:190:3: undefined: Free
../../ristretto/z/allocator.go:207:3: undefined: Free
../../ristretto/z/allocator.go:274:9: undefined: Calloc
../../ristretto/z/buffer.go:116:3: undefined: Free
../../ristretto/z/buffer.go:149:11: undefined: Calloc
../../ristretto/z/buffer.go:222:14: undefined: Calloc
../../ristretto/z/buffer.go:224:4: undefined: Free
../../ristretto/z/buffer.go:502:3: undefined: Free
Makefile:78: recipe for target 'dgraph' failed

actually, the ristretto/z/buffer.go has no problem;
i think it maybe casused by cgo, so i make dgraph with CGO_ENABLED=1,
this time, it works well; but when i copy the dgraph binary to docker container, it can’t work,
get faults:

sh: ./dgraph: not found

why?dgraph cannot compile with CGO_ENABLED=0? or i cannot use my own docker image, my docker image is alpine:3.11

Is there document about how to compile dgraph by self?i’m not found

A “not found” error doesn’t sound like a compilation issue. Did you run the right path to the Dgraph binary in your container?

You can compile Dgraph using the Makefile in the repo.

  • make install (installs to your GOBIN), or
  • make dgraph (creates the dgraph binary in the dgraph subdirectory)

I don’t know how well that works in Alpine.

Do note that not found is also the error you get in a Linux shell when it tries to execute a binary compiled for a different and unsupported architecture.

The CGO_ENABLED thing is a bug. I’m marking this as an issue. I’ll fix it on monday.

PR is here . Will inform you when pushed.