add new Dockerfile with multi-stage build that produces a single binary docker image

This commit is contained in:
Philipp Böhm 2021-02-21 14:44:32 +01:00
parent 26e2df7c77
commit e62dbbda94
2 changed files with 19 additions and 2 deletions

View File

@ -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

17
Dockerfile Normal file
View File

@ -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"]