From 9592b0dd52cac9760539fc251e28c5235a7b06c8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20S=C3=BC=C3=9F?= Date: Tue, 22 Jun 2021 17:18:08 +0200 Subject: [PATCH] feat: publish container images --- .github/workflows/release.yml | 13 +++++++++++++ .goreleaser.yml | 35 +++++++++++++++++++++++++++++++++++ Dockerfile | 19 +------------------ 3 files changed, 49 insertions(+), 18 deletions(-) create mode 100644 .goreleaser.yml diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index f702d7a..8b5007d 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -19,6 +19,16 @@ jobs: uses: actions/checkout@v2 with: fetch-depth: 0 + - name: Set up QEMU + uses: docker/setup-qemu-action@v1 + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v1 + - name: Docker Login + uses: docker/login-action@v1 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} - name: Set up Go uses: actions/setup-go@v2 with: @@ -31,3 +41,6 @@ jobs: args: release --rm-dist env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + - name: Clear + if: always() + run: rm -f ${HOME}/.docker/config.json diff --git a/.goreleaser.yml b/.goreleaser.yml new file mode 100644 index 0000000..c84c8fd --- /dev/null +++ b/.goreleaser.yml @@ -0,0 +1,35 @@ +# This is an example .goreleaser.yml file with some sane defaults. +# Make sure to check the documentation at http://goreleaser.com +before: + hooks: + # You may remove this if you don't use go modules. + - go mod tidy +builds: + - env: + - CGO_ENABLED=0 + goos: + - linux + - windows + - darwin +archives: + - replacements: + darwin: Darwin + linux: Linux + windows: Windows + 386: i386 + amd64: x86_64 +dockers: + - image_templates: + - 'ghcr.io/parkour-vienna/distrust:{{ .Version }}' +checksum: + name_template: 'checksums.txt' +snapshot: + name_template: '{{ .Tag }}-next' +changelog: + sort: asc + filters: + exclude: + - '^docs:' + - '^test:' + - '^chore:' + - '^Merge pull request' diff --git a/Dockerfile b/Dockerfile index 2515ea8..5200cce 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,25 +1,8 @@ -# Build the manager binary -FROM golang:1.16 as builder - -WORKDIR /workspace -# Copy the Go Modules manifests -COPY go.mod go.mod -COPY go.sum go.sum -# cache deps before building and copying source so that we don't need to re-download as much -# and so that source changes don't invalidate our downloaded layer -RUN go mod download - -# Copy the go source -COPY . /workspace - -# Build -RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 GO111MODULE=on go build -a -o distrust . - # Use distroless as minimal base image to package the distrust binary # Refer to https://github.com/GoogleContainerTools/distroless for more details FROM gcr.io/distroless/static:nonroot WORKDIR / -COPY --from=builder /workspace/distrust . +COPY distrust / USER nonroot:nonroot ENTRYPOINT ["/distrust"]