Skip to content

Commit e39700a

Browse files
fix: publish distroless Docker image with dockers v2 (#716)
* fix: publish distroless docker image with dockers v2 * fix: sign distroless docker image by digest
1 parent f013c4c commit e39700a

4 files changed

Lines changed: 36 additions & 67 deletions

File tree

.github/workflows/main.yaml

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -220,8 +220,16 @@ jobs:
220220
ARTIFACTS: "${{ steps.goreleaser.outputs.artifacts }}"
221221
run: |
222222
set -euo pipefail
223-
artifact=$(echo "$ARTIFACTS" | jq -r '[.[] | select (.type=="Docker Manifest")][0]')
224-
image=$(echo "$artifact" | jq -r '.path' | cut -d':' -f1)
223+
artifact=$(
224+
echo "$ARTIFACTS" | jq -er --arg image_tag "openfga/cli:${GITHUB_REF_NAME}" '
225+
[
226+
.[]
227+
| select(.type == "Docker Image")
228+
| select(.path == $image_tag)
229+
| select(((.extra.Platforms // []) | index("linux/amd64")) and ((.extra.Platforms // []) | index("linux/arm64")))
230+
][0]
231+
'
232+
)
225233
digest=$(echo "$artifact" | jq -r '.extra.Digest')
226234
echo "digest=$digest" >> "$GITHUB_OUTPUT"
227235

.goreleaser.Dockerfile

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1-
FROM scratch
2-
COPY fga /fga
3-
ENTRYPOINT ["/fga"]
1+
FROM gcr.io/distroless/static-debian13:nonroot
2+
3+
ARG TARGETPLATFORM
4+
COPY ${TARGETPLATFORM}/fga /fga
5+
ENTRYPOINT ["/fga"]

.goreleaser.yaml

Lines changed: 19 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -24,68 +24,25 @@ builds:
2424
- "-X github.com/openfga/cli/internal/build.Commit={{.Commit}}"
2525
- "-X github.com/openfga/cli/internal/build.Date={{.Date}}"
2626

27-
dockers:
28-
- goos: linux
29-
goarch: amd64
30-
27+
dockers_v2:
28+
- images:
29+
- openfga/cli
30+
tags:
31+
- latest
32+
- "{{ .Tag }}"
33+
- "v{{ .Major }}"
34+
- "v{{ .Major }}.{{ .Minor }}"
3135
dockerfile: .goreleaser.Dockerfile
32-
33-
image_templates:
34-
- "openfga/cli:latest-amd64"
35-
- "openfga/cli:{{ .Tag }}-amd64"
36-
- "openfga/cli:v{{ .Version }}-amd64"
37-
- "openfga/cli:v{{ .Major }}-amd64"
38-
- "openfga/cli:v{{ .Major }}.{{ .Minor }}-amd64"
39-
- "openfga/cli:v{{ .Major }}.{{ .Minor }}.{{ .Patch }}-amd64"
40-
41-
use: buildx
42-
build_flag_templates:
43-
- "--platform=linux/amd64"
36+
platforms:
37+
- linux/amd64
38+
- linux/arm64
39+
labels:
40+
org.opencontainers.image.created: "{{ .Date }}"
41+
org.opencontainers.image.title: "{{ .ProjectName }}"
42+
org.opencontainers.image.revision: "{{ .FullCommit }}"
43+
org.opencontainers.image.version: "{{ .Version }}"
44+
flags:
4445
- "--pull"
45-
- "--label=org.opencontainers.image.created={{.Date}}"
46-
- "--label=org.opencontainers.image.title={{.ProjectName}}"
47-
- "--label=org.opencontainers.image.revision={{.FullCommit}}"
48-
- "--label=org.opencontainers.image.version={{.Version}}"
49-
50-
- goos: linux
51-
goarch: arm64
52-
53-
dockerfile: .goreleaser.Dockerfile
54-
55-
image_templates:
56-
- "openfga/cli:latest-arm64"
57-
- "openfga/cli:{{ .Tag }}-arm64"
58-
- "openfga/cli:v{{ .Version }}-arm64"
59-
- "openfga/cli:v{{ .Major }}-arm64"
60-
- "openfga/cli:v{{ .Major }}.{{ .Minor }}-arm64"
61-
- "openfga/cli:v{{ .Major }}.{{ .Minor }}.{{ .Patch }}-arm64"
62-
63-
use: buildx
64-
65-
build_flag_templates:
66-
- "--platform=linux/arm64"
67-
68-
docker_manifests:
69-
- name_template: openfga/cli:latest
70-
image_templates:
71-
- openfga/cli:latest-amd64
72-
- openfga/cli:latest-arm64
73-
- name_template: openfga/cli:v{{ .Version }}
74-
image_templates:
75-
- openfga/cli:v{{ .Version }}-amd64
76-
- openfga/cli:v{{ .Version }}-arm64
77-
- name_template: openfga/cli:v{{ .Major }}
78-
image_templates:
79-
- openfga/cli:v{{ .Major }}-amd64
80-
- openfga/cli:v{{ .Major }}-arm64
81-
- name_template: openfga/cli:v{{ .Major }}.{{ .Minor }}
82-
image_templates:
83-
- openfga/cli:v{{ .Major }}.{{ .Minor }}-amd64
84-
- openfga/cli:v{{ .Major }}.{{ .Minor }}-arm64
85-
- name_template: openfga/cli:v{{ .Major }}.{{ .Minor }}.{{ .Patch }}
86-
image_templates:
87-
- openfga/cli:v{{ .Major }}.{{ .Minor }}.{{ .Patch }}-amd64
88-
- openfga/cli:v{{ .Major }}.{{ .Minor }}.{{ .Patch }}-arm64
8946

9047
release:
9148
draft: true
@@ -116,11 +73,11 @@ docker_signs:
11673
- cmd: cosign
11774
env:
11875
- COSIGN_EXPERIMENTAL=1
119-
artifacts: manifests
76+
artifacts: images
12077
output: true
12178
args:
12279
- 'sign'
123-
- '${artifact}'
80+
- '${artifact}@${digest}'
12481
- "--yes" # needed on cosign 2.0.0+
12582

12683
brews:

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,8 @@ scoop install openfga
9898
docker pull openfga/cli; docker run -it openfga/cli
9999
```
100100

101+
The Docker image is multi-platform and includes the system CA certificates needed for endpoints that use publicly trusted certificate authorities. Private or internal CAs still need to be provided by the user.
102+
101103
### Go
102104

103105
```shell

0 commit comments

Comments
 (0)