Docker alpine

Moved from GitHub dgraph/3221

Posted by pjebs:

Is it possible for official docker image to use alpine distribution of linux.

All the other main databases provided at a minimum an alpine version.

Alpine simply has a smaller size footprint.

mangalaman93 commented :

For now, you could use the following Dockerfile for creating an alpine based image. We will see if it is possible to add this to official docker images.

######################
# STEP 1 build dgraph
######################
FROM golang:1.12-alpine3.9 AS builder

# build custom branch
ARG DGRAPH_BRANCH=master

# Install git
RUN apk update && apk add --no-cache git

# build dgraph binary
RUN go get -d -v github.com/dgraph-io/dgraph/dgraph
RUN cd $GOPATH/src/github.com/dgraph-io/dgraph && git checkout ${DGRAPH_BRANCH}
RUN CGO_ENABLED=0 go build -v -o /dgraph github.com/dgraph-io/dgraph/dgraph

#####################
# STEP 2 build image
#####################
FROM alpine

COPY --from=builder /dgraph /usr/local/bin/dgraph

RUN mkdir /dgraph
WORKDIR /dgraph

EXPOSE 8080
EXPOSE 9080

CMD ["dgraph"]

mangalaman93 commented :

Possible reasons to use Alpine image -

  • Alpine based image reduce the attack surface area
  • Smaller in size compared to Ubuntu based image

mangalaman93 commented :

Todo: Need to install ca-certificates in the image so that telemetry can work.