update Dockerfile to work with go mod
-FROM golang:1.9.2-alpine3.6 AS build
-ARG BRANCH=master
-RUN apk add --no-cache make git
-
-RUN go get -u github.com/grpc-ecosystem/grpc-gateway/protoc-gen-grpc-gateway
-RUN go get -u github.com/grpc-ecosystem/grpc-gateway/protoc-gen-swagger
-RUN go get -u github.com/golang/protobuf/protoc-gen-go
-RUN go get -u github.com/kardianos/govendor
-RUN echo ${BRANCH}
-RUN mkdir -p src/github.com/spacemeshos; cd src/github.com/spacemeshos; git clone https://github.com/spacemeshos/go-spacemesh; cd go-spacemesh; git checkout ${BRANCH}; go build; govendor sync; make
-RUN cp /go/src/github.com/spacemeshos/go-spacemesh/config.toml /go
-
-ENTRYPOINT /go/src/github.com/spacemeshos/go-spacemesh/go-spacemesh
+# Base build image
+FROM golang:1.11.2-alpine3.8 AS build_base
+RUN apk add bash make git curl unzip rsync libc6-compat gcc musl-dev
+WORKDIR /go/src/github.com/spacemeshos/go-spacemesh
+
+# Force the go compiler to use modules
+ENV GO111MODULE=on
+
+# We want to populate the module cache based on the go.{mod,sum} files.
+COPY go.mod .
+COPY go.sum .
+
+# Download dependencies
+RUN go mod download
+
+COPY setup_env.sh .
+COPY scripts/* scripts/
+
+RUN ./setup_env.sh
+
+# This image builds the go-spacemesh server
+FROM build_base AS server_builder
+# Here we copy the rest of the source code
+COPY . .
+
+# And compile the project
+RUN make build
+
+#In this last stage, we start from a fresh Alpine image, to reduce the image size and not ship the Go compiler in our production artifacts.
+FROM alpine AS spacemesh
+
+# Finally we copy the statically compiled Go binary.
+COPY --from=server_builder /go/src/github.com/spacemeshos/go-spacemesh/go-spacemesh /bin/go-spacemesh
+ENTRYPOINT ["/bin/go-spacemesh"]
EXPOSE 7513
