diff --git a/Dockerfile b/Dockerfile index d522c035..0d4dcb7b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,11 +1,22 @@ -FROM alpine:latest -ENTRYPOINT ["/bin/matterbridge"] +FROM alpine:latest AS builder + +ENV CGOENABLE 1 +ENV GOPATH /go +ENV GO111MODULE on + +RUN apk update && apk add go git gcc musl-dev linux-headers COPY . /go/src/github.com/42wim/matterbridge -RUN apk update && apk add go git gcc musl-dev ca-certificates \ - && cd /go/src/github.com/42wim/matterbridge \ - && export GOPATH=/go \ - && go get \ - && go build -x -ldflags "-X main.githash=$(git log --pretty=format:'%h' -n 1)" -o /bin/matterbridge \ - && rm -rf /go \ - && apk del --purge git go gcc musl-dev + +WORKDIR /go/src/github.com/42wim/matterbridge + +RUN go get +RUN go build -x -ldflags "-X main.githash=$(git log --pretty=format:'%h' -n 1)" -o /bin/matterbridge + +FROM alpine:latest + +RUN apk update && apk add ca-certificates + +COPY --from=builder /bin/matterbridge /bin/matterbridge + +ENTRYPOINT ["/bin/matterbridge"]