From 1177c2527181cc8eb13ce29587562c25fcc0170f Mon Sep 17 00:00:00 2001 From: Travis Ralston Date: Wed, 6 Jun 2018 16:22:17 -0600 Subject: [PATCH] Convert Dockerfile to be a mutlistage build Signed-off-by: Travis Ralston --- Dockerfile | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/Dockerfile b/Dockerfile index 7731c2f..c5e6d6d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,19 +1,20 @@ -FROM alpine:3.6 - -ENV BIND_ADDRESS=:4050 DATABASE_TYPE=sqlite3 DATABASE_URL=/data/go-neb.db?_busy_timeout=5000 +# Build go-neb +FROM golang:1.8-alpine as builder COPY . /tmp/go-neb WORKDIR /tmp/go-neb -ENV GOPATH=/tmp/go-neb/vendor/src:/tmp/go-neb/vendor:/tmp/go-neb RUN apk add --no-cache -t build-deps git gcc musl-dev go \ && go get -u github.com/constabulary/gb/... \ - && export PATH="/tmp/go-neb/vendor/src/bin:${PATH}" \ && gb vendor restore \ - && gb build -f github.com/matrix-org/go-neb \ - && mv bin/go-neb /go-neb \ - && cd / \ - && rm -rf /tmp/* \ - && apk del build-deps + && gb build -f github.com/matrix-org/go-neb + + +# Run go-neb +FROM alpine:3.6 + +ENV BIND_ADDRESS=:4050 DATABASE_TYPE=sqlite3 DATABASE_URL=/data/go-neb.db?_busy_timeout=5000 + +COPY --from=builder /tmp/go-neb/bin/go-neb /go-neb VOLUME /data EXPOSE 4050