improve the Dockerfile

Signed-off-by: Jakub Sokołowski <jakub@status.im>
This commit is contained in:
Jakub Sokołowski 2019-10-15 13:31:01 +02:00
parent 768539255a
commit 4be225c388
No known key found for this signature in database
GPG Key ID: 4EF064D0E6D63020

View File

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