From 575415311ea629b81457f8091090fb498bfaccba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miguel=20Mart=C3=ADnez=20Trivi=C3=B1o?= Date: Tue, 11 Jan 2022 08:48:07 -0800 Subject: [PATCH] feat: Release container images into Github Packages repository (#128) --- .github/workflows/goreleaser.yml | 6 ++++++ .goreleaser.yml | 11 +++++++++++ Dockerfile | 20 +++++++------------- 3 files changed, 24 insertions(+), 13 deletions(-) diff --git a/.github/workflows/goreleaser.yml b/.github/workflows/goreleaser.yml index 8863f2f0..e6ef160e 100644 --- a/.github/workflows/goreleaser.yml +++ b/.github/workflows/goreleaser.yml @@ -16,6 +16,12 @@ jobs: uses: actions/checkout@v2 - name: Unshallow run: git fetch --prune --unshallow + - name: Docker login to Github Packages + uses: docker/login-action@v1 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} - name: Set up Go uses: actions/setup-go@v1 with: diff --git a/.goreleaser.yml b/.goreleaser.yml index ef688e7f..a537c840 100644 --- a/.goreleaser.yml +++ b/.goreleaser.yml @@ -7,6 +7,17 @@ builds: ldflags: - -X github.com/vmware-tanzu/asset-relocation-tool-for-kubernetes/cmd.Version={{ .Version }} binary: relok8s +dockers: + - + dockerfile: Dockerfile + image_templates: + - "ghcr.io/vmware-tanzu/asset-relocation-tool-for-kubernetes:{{ .Tag }}" + - "ghcr.io/vmware-tanzu/asset-relocation-tool-for-kubernetes:latest" + build_flag_templates: + - "--build-arg" + - "VERSION={{ .Version }}" + extra_files: + - assets/docker-login.sh archives: - replacements: 386: i386 diff --git a/Dockerfile b/Dockerfile index 84eaf49a..8f73dfae 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,23 +1,17 @@ # Copyright 2021 VMware, Inc. # SPDX-License-Identifier: BSD-2-Clause -FROM golang:1.17 as builder -ARG VERSION - -COPY . /asset-relocation-tool-for-kubernetes/ -ENV GOPATH= -ENV PATH="${PATH}:/root/go/bin" -WORKDIR /asset-relocation-tool-for-kubernetes/ -RUN make test && make build +# Distributes the relok8s binary previously crafted by the release process +# as part of the CI release action FROM photon:4.0 +ARG VERSION +ENV VERSION=${VERSION} + LABEL description="Asset Relocation Tool for Kubernetes" LABEL maintainer="tanzu-isv-engineering@groups.vmware.com" - -WORKDIR / - -RUN yum -y install diffutils jq +LABEL org.opencontainers.image.source https://github.com/vmware-tanzu/asset-relocation-tool-for-kubernetes COPY assets/docker-login.sh /usr/local/bin/docker-login.sh -COPY --from=builder /asset-relocation-tool-for-kubernetes/build/relok8s /usr/local/bin/relok8s +COPY ./relok8s /usr/local/bin ENTRYPOINT ["/usr/local/bin/relok8s"]