From e62dbbda9433022dcfcdd3a0b0851cfe5b280ac8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philipp=20B=C3=B6hm?= Date: Sun, 21 Feb 2021 14:44:32 +0100 Subject: [PATCH] add new Dockerfile with multi-stage build that produces a single binary docker image --- .circleci/config.yml | 4 ++-- Dockerfile | 17 +++++++++++++++++ 2 files changed, 19 insertions(+), 2 deletions(-) create mode 100644 Dockerfile diff --git a/.circleci/config.yml b/.circleci/config.yml index e99dff8..dd7b7a2 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -18,7 +18,7 @@ jobs: - checkout - docker/build: image: pboehm/ddns - dockerfile: docker/ddns/Dockerfile + dockerfile: Dockerfile docker-build-and-push: executor: docker/docker @@ -28,7 +28,7 @@ jobs: - docker/check - docker/build: image: pboehm/ddns - dockerfile: docker/ddns/Dockerfile + dockerfile: Dockerfile tag: $CIRCLE_SHA1,latest - docker/push: image: pboehm/ddns diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..744fa3a --- /dev/null +++ b/Dockerfile @@ -0,0 +1,17 @@ +FROM golang:alpine AS builder + +RUN apk add --no-cache git + +WORKDIR /go/src/github.com/pboehm/ddns +COPY . . + +RUN GO111MODULE=on go get -d -v ./... +RUN export CGO_ENABLED=0 && GO111MODULE=on go install -v ./... + +ENV GIN_MODE release + +FROM scratch + +COPY --from=builder /go/bin/ddns /go/bin/ddns + +ENTRYPOINT ["/go/bin/ddns"]