From cf9a2a496d97d8aaa41c0ae97ba604d75b7b2099 Mon Sep 17 00:00:00 2001 From: Joost van der Griendt Date: Wed, 13 May 2020 22:59:24 +0200 Subject: [PATCH] use multi-stage build image --- .github/workflows/build.yml | 4 ---- Dockerfile | 15 ++++++++++++--- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 741fe2b..1603e39 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -66,10 +66,6 @@ jobs: steps: - name: Checkout uses: actions/checkout@v2 - - name: get dependency - run: go get -t -v ./... - - name: build - run: make linux # Setup gcloud CLI - uses: GoogleCloudPlatform/github-actions/setup-gcloud@master with: diff --git a/Dockerfile b/Dockerfile index e863e6a..501acb0 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,14 @@ -FROM scratch +FROM golang:1.14 as builder +WORKDIR /go/src/cmg +COPY go.* ./ +RUN go mod download +COPY . ./ +RUN CGO_ENABLED=0 GOOS=linux go build -v -o cmg + +FROM alpine:3 +RUN apk --no-cache add ca-certificates EXPOSE 8080 -ENTRYPOINT ["/cmg"] +ENV PORT=8080 +ENTRYPOINT ["/usr/bin/cmg"] CMD ["serve"] -COPY ./bin/ /usr/bin +COPY --from=builder /go/src/cmg/cmg /usr/bin/cmg \ No newline at end of file