From 0f548b56f42b3b2ead12e0e40e81c8861ea44957 Mon Sep 17 00:00:00 2001 From: mskarbe Date: Fri, 26 Jun 2020 15:08:43 +0200 Subject: [PATCH] prepare docker image for quay, pushing via goreleaser --- .goreleaser.yml | 31 +++++++++++++++++++++++++++++++ Dockerfile | 29 +++++++++++++++++++++++++++++ 2 files changed, 60 insertions(+) create mode 100644 Dockerfile diff --git a/.goreleaser.yml b/.goreleaser.yml index 13188a6..c49f393 100644 --- a/.goreleaser.yml +++ b/.goreleaser.yml @@ -26,3 +26,34 @@ checksum: snapshot: name_template: "{{ .Tag }}-snapshot" + +# to push to quay +dockers: + - + # GOOS of the built binary that should be used. + goos: linux + + # GOARCH of the built binary that should be used. + goarch: amd64 + + # Name templates of the built binaries that should be used. + binaries: + - gman + + # Templates of the Docker image names. + image_templates: + - "quay.io/kubermatic-labs/gman:{{ .Tag }}" + + # Skips the docker push. Could be useful if you also do draft releases. + skip_push: false + + # Path to the Dockerfile (from the project root). + dockerfile: Dockerfile + + # If your Dockerfile copies files other than the binary itself, + # you should list them here as well. + # the paths here are relative to the folder in which goreleaser is being run. + #extra_files: + #- README.md + #- LICENSE + #- config.example.yaml \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..9757b7a --- /dev/null +++ b/Dockerfile @@ -0,0 +1,29 @@ +FROM golang:alpine AS builder +RUN apk add git +# necessary environmet variables +ENV GO111MODULE=on \ + CGO_ENABLED=0 \ + GOOS=linux \ + GOARCH=amd64 + +WORKDIR /build +COPY go.mod . +COPY go.sum . +RUN go mod download + +# Copy the code into the container & build +COPY main.go . +RUN go build -o gman main.go + +WORKDIR /app + +# Copy binary from build to main folder +RUN cp /build/gman . + +# Build a small image +FROM scratch + +COPY --from=builder /app/gman / + +# Command to run +ENTRYPOINT ["/gman"] \ No newline at end of file