From 4b329dc9cb2d85622315201d6fdcdbac03c02918 Mon Sep 17 00:00:00 2001 From: Michael Beemer Date: Tue, 22 Oct 2024 14:37:28 -0400 Subject: [PATCH] ci: add docker publish (#37) Signed-off-by: Michael Beemer --- .github/workflows/release.yaml | 17 ++++++++++++--- .goreleaser.yaml | 38 ++++++++++++++++++++++++++++++++++ Dockerfile | 7 +++++++ 3 files changed, 59 insertions(+), 3 deletions(-) create mode 100644 Dockerfile diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 0a426d7..3be0393 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -33,10 +33,13 @@ jobs: go-release: needs: release-please + if: ${{ fromJSON(needs.release-please.outputs.release_created) }} runs-on: ubuntu-latest permissions: contents: write - if: ${{ fromJSON(needs.release-please.outputs.release_created) }} + packages: write + env: + DOCKER_CLI_EXPERIMENTAL: "enabled" steps: - name: Checkout uses: actions/checkout@v4 @@ -44,6 +47,16 @@ jobs: fetch-depth: 0 ref: ${{ needs.release-please.outputs.release_tag_name }} + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + + - name: Login to GitHub Container Registry + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.repository_owner }} + password: ${{ secrets.GITHUB_TOKEN }} + - name: Set up Go uses: actions/setup-go@v5 with: @@ -52,9 +65,7 @@ jobs: - name: Run GoReleaser uses: goreleaser/goreleaser-action@v6 with: - # either 'goreleaser' (default) or 'goreleaser-pro' distribution: goreleaser - # 'latest', 'nightly', or a semver version: "~> v2" args: release --clean env: diff --git a/.goreleaser.yaml b/.goreleaser.yaml index c30130a..1b50a93 100644 --- a/.goreleaser.yaml +++ b/.goreleaser.yaml @@ -38,3 +38,41 @@ archives: format: zip report_sizes: true + +dockers: +- image_templates: ["ghcr.io/open-feature/codegen:{{ .Version }}-amd64"] + dockerfile: Dockerfile + use: buildx + build_flag_templates: + - --platform=linux/amd64 + - --label=org.opencontainers.image.title={{ .ProjectName }} + - --label=org.opencontainers.image.url=https://github.com/open-feature/codegen + - --label=org.opencontainers.image.source=https://github.com/open-feature/codegen + - --label=org.opencontainers.image.version={{ .Version }} + - --label=org.opencontainers.image.created={{ time "2006-01-02T15:04:05Z07:00" }} + - --label=org.opencontainers.image.revision={{ .FullCommit }} + - --label=org.opencontainers.image.licenses=Apache-2.0 + +- image_templates: ["ghcr.io/open-feature/codegen:{{ .Version }}-arm64"] + goarch: arm64 + dockerfile: Dockerfile + use: buildx + build_flag_templates: + - --platform=linux/arm64 + - --label=org.opencontainers.image.title={{ .ProjectName }} + - --label=org.opencontainers.image.url=https://github.com/open-feature/codegen + - --label=org.opencontainers.image.source=https://github.com/open-feature/codegen + - --label=org.opencontainers.image.version={{ .Version }} + - --label=org.opencontainers.image.created={{ time "2006-01-02T15:04:05Z07:00" }} + - --label=org.opencontainers.image.revision={{ .FullCommit }} + - --label=org.opencontainers.image.licenses=Apache-2.0 + +docker_manifests: +- name_template: ghcr.io/open-feature/codegen:{{ .Version }} + image_templates: + - ghcr.io/open-feature/codegen:{{ .Version }}-amd64 + - ghcr.io/open-feature/codegen:{{ .Version }}-arm64 +- name_template: ghcr.io/open-feature/codegen:latest + image_templates: + - ghcr.io/open-feature/codegen:{{ .Version }}-amd64 + - ghcr.io/open-feature/codegen:{{ .Version }}-arm64 \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..a3f9b41 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,7 @@ +# Use distroless as minimal base image to package the manager binary +# Refer to https://github.com/GoogleContainerTools/distroless for more details +FROM gcr.io/distroless/static:nonroot +COPY openfeature . +USER 65532:65532 + +ENTRYPOINT ["/openfeature"] \ No newline at end of file