From 5a7e92955eabc08ab173fff6fce8ba88ca212676 Mon Sep 17 00:00:00 2001 From: Nicolas Vanheuverzwijn Date: Fri, 2 Oct 2020 11:26:21 -0400 Subject: [PATCH] docker: add Dockerfile and .dockerignore. The Dockerfile produces a scratch image with a statically linked binary without debug flag. --- .dockerignore | 6 ++++++ Dockerfile | 8 ++++++++ 2 files changed, 14 insertions(+) create mode 100644 .dockerignore create mode 100644 Dockerfile diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 00000000..956a9c52 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,6 @@ +* +!go.mod +!go.sum +!*.go +!Makefile +!internal/* diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 00000000..abc7c9a1 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,8 @@ +FROM golang:1.14 AS builder +WORKDIR /go/src/github.com/adnanh/webhook/ +COPY . ./ +RUN make CGO_ENABLED=0 LDFLAGS="-w -s" build + +FROM scratch +COPY --from=builder /go/src/github.com/adnanh/webhook/webhook /bin/ +ENTRYPOINT ["/bin/webhook"]