From 276d8f78498278a8ce96bbb90f4b7de66d974077 Mon Sep 17 00:00:00 2001 From: James Mills Date: Thu, 17 May 2018 15:39:46 -0700 Subject: [PATCH] Improved Dockerfile to properly build and ship a runtime image --- .gitignore | 1 + Dockerfile | 21 ++++++++++++++++++--- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/.gitignore b/.gitignore index bc0c8119..8f4c9b43 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ build release +dispatch client/dist client/node_modules client/yarn-error.log diff --git a/Dockerfile b/Dockerfile index b258b62a..f8cc86d5 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,7 +1,22 @@ -FROM scratch +# Build +FROM golang:alpine AS build -ADD build/dispatch / -ADD ca-certificates.crt /etc/ssl/certs/ +RUN apk add --update git make build-base && \ + rm -rf /var/cache/apk/* + +WORKDIR /go/src/github.com/khlieng/dispatch +COPY . /go/src/github.com/khlieng/dispatch +RUN go build . + +# Runtime +FROM alpine + +RUN apk add --update ca-certificates && \ + rm -rf /var/cache/apk/* + +COPY --from=build /go/src/github.com/khlieng/dispatch/dispatch /dispatch + +EXPOSE 80/tcp VOLUME ["/data"]