Dgraph: Docker alpine

Created on 28 Mar 2019  路  4Comments  路  Source: dgraph-io/dgraph

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.

aretools kinenhancement prioritP2 statuaccepted

Most helpful comment

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"]

All 4 comments

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"]

Possible reasons to use Alpine image -

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

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

Github issues have been deprecated.
This issue has been moved to discuss. You can follow the conversation there and also subscribe to updates by changing your notification preferences.

drawing

Was this page helpful?
0 / 5 - 0 ratings

Related issues

mbudge picture mbudge  路  3Comments

djdoeslinux picture djdoeslinux  路  4Comments

ShawnMilo picture ShawnMilo  路  4Comments

MichelDiz picture MichelDiz  路  3Comments

pepoospina picture pepoospina  路  3Comments