Skip to content

Commit 2282139

Browse files
committed
feat: better build process for operators
1 parent a371729 commit 2282139

File tree

8 files changed

+155
-24
lines changed

8 files changed

+155
-24
lines changed

.github/workflows/build-dexop.yaml

Lines changed: 35 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,36 @@ on:
1010
- "go/dexop/**"
1111

1212
jobs:
13-
build-ghcr-registry:
13+
build-dexop:
1414
runs-on: ubuntu-latest
1515
permissions:
1616
packages: write
17-
contents: read
17+
contents: write
18+
id-token: write
1819
steps:
19-
- uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6
20+
- name: Checkout
21+
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6
22+
with:
23+
fetch-depth: 0
24+
25+
- name: Install Go
26+
uses: actions/setup-go@4dc6199c7b1a012772edbd06daecab0f50c9053c # v6
27+
with:
28+
go-version: '1.24'
29+
cache: true
30+
cache-dependency-path: 'go/dexop/go.sum'
31+
32+
- name: Install syft
33+
uses: anchore/sbom-action/download-syft@0b82b0b1a22399a1c542d4d656f70cd903571b5c # v0.21.1
34+
35+
- name: Install Cosign
36+
uses: sigstore/cosign-installer@faadad0cce49287aee09b3a48701e75088a2c6ad # v4.0.0
37+
38+
- name: Set up QEMU
39+
uses: docker/setup-qemu-action@29109295f81e9208d7d86ff1c6c12d2833863392 # v3.6.0
40+
2041
- name: Set up Docker Buildx
21-
uses: docker/setup-buildx-action@8d2750c68a42422c14e847fe6c8ac0403b4cbd6f # v3
42+
uses: docker/setup-buildx-action@e468171a9de216ec08956ac3ada2f0791b6bd435 # v3.11.1
2243

2344
- name: Login to ghcr.io
2445
uses: docker/login-action@5e57cd118135c172c3672efd75eb46360885c0ef # v3
@@ -31,13 +52,14 @@ jobs:
3152
id: extract_tag
3253
run: echo "tag=${GITHUB_REF#refs/tags/dexop-v}" >> $GITHUB_OUTPUT
3354

34-
- name: Build and deploy Dexop image
35-
uses: docker/build-push-action@263435318d21b8e681c14492fe198d362a7d2c83 # v6
55+
- name: Run GoReleaser
56+
uses: goreleaser/goreleaser-action@e435ccd777264be153ace6237001ef4d979d3a7a # v6
3657
with:
37-
context: go/dexop/
38-
file: go/dexop/Dockerfile
39-
# push for all main branch commits
40-
push: ${{ github.event_name != 'pull_request' }}
41-
tags: ghcr.io/${{ github.repository }}/dexop:latest,ghcr.io/${{ github.repository }}/dexop:${{ steps.extract_tag.outputs.tag }}
42-
labels: |
43-
org.opencontainers.image.version=${{ steps.extract_tag.outputs.tag }}
58+
distribution: goreleaser
59+
version: "~> v2"
60+
args: release --clean --skip=validate
61+
workdir: go/dexop
62+
env:
63+
GIT_REPO: ${{ github.repository }}
64+
CUSTOM_TAG: ${{ steps.extract_tag.outputs.tag }}
65+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/build-nautobotop.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ jobs:
6060
args: release --clean --skip=validate
6161
workdir: go/nautobotop
6262
env:
63+
GIT_REPO: ${{ github.repository }}
6364
CUSTOM_TAG: ${{ steps.extract_tag.outputs.tag }}
6465
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
6566

go/dexop/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ Dockerfile.cross
1515

1616
# Go workspace file
1717
go.work
18+
vendor/
19+
dist/
1820

1921
# Kubernetes Generated files - skip generated files, except for vendored files
2022
!vendor/**/zz_generated.*

go/dexop/.goreleaser.Dockerfile

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# goreleaser is making the binary dynamically linked so can't use the static container
2+
FROM gcr.io/distroless/base-debian12:nonroot
3+
COPY --chmod=555 dexop /usr/local/bin/dexop
4+
USER 65532:65532
5+
ENTRYPOINT ["/usr/local/bin/dexop"]

go/dexop/.goreleaser.yaml

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
project_name: "dexop"
2+
version: 2
3+
4+
before:
5+
hooks:
6+
- go mod tidy
7+
8+
env:
9+
- CUSTOM_TAG={{ .Env.CUSTOM_TAG }}
10+
- GIT_REPO={{ .Env.GIT_REPO }}
11+
12+
builds:
13+
- main: main.go
14+
dir: ./cmd
15+
binary: dexop
16+
goos: ["linux"]
17+
goarch: ["amd64", "arm64"]
18+
flags:
19+
- -trimpath
20+
ldflags:
21+
- -s
22+
- -w
23+
- -X main.version={{.Version}}
24+
- -X main.commit={{.ShortCommit}}
25+
env:
26+
- CGO_ENABLED=0
27+
28+
changelog:
29+
disable: true
30+
31+
dockers:
32+
- skip_push: false
33+
use: buildx
34+
dockerfile: .goreleaser.Dockerfile
35+
image_templates:
36+
- ghcr.io/{{ .Env.GIT_REPO }}/{{ .ProjectName }}:{{ .Env.CUSTOM_TAG }}-amd64
37+
build_flag_templates:
38+
- --platform=linux/amd64
39+
- --label=org.opencontainers.image.version={{ .Env.CUSTOM_TAG }}
40+
- --label=org.opencontainers.image.revision={{ .Commit }}
41+
- --label=org.opencontainers.image.title={{ .ProjectName }}
42+
- --label=org.opencontainers.image.created={{ .Date }}
43+
- --label=org.opencontainers.image.description=Rackspace Cloud DNS support for cert-manager
44+
- --label=org.opencontainers.image.vendor=rackspace
45+
- --label=org.opencontainers.image.licenses=Apache License 2.0
46+
- --label=org.opencontainers.image.source=https://rackspace.com/
47+
- --label=org.opencontainers.image.authors=Rackspace
48+
- skip_push: false
49+
goarch: arm64
50+
use: buildx
51+
dockerfile: .goreleaser.Dockerfile
52+
image_templates:
53+
- ghcr.io/{{ .Env.GIT_REPO }}/{{ .ProjectName }}:{{ .Env.CUSTOM_TAG }}-arm64
54+
build_flag_templates:
55+
- --platform=linux/arm64
56+
- --label=org.opencontainers.image.version={{ .Env.CUSTOM_TAG }}
57+
- --label=org.opencontainers.image.revision={{ .Commit }}
58+
- --label=org.opencontainers.image.title={{ .ProjectName }}
59+
- --label=org.opencontainers.image.created={{ .Date }}
60+
- --label=org.opencontainers.image.description=Rackspace Cloud DNS support for cert-manager
61+
- --label=org.opencontainers.image.vendor=rackspace
62+
- --label=org.opencontainers.image.licenses=Apache License 2.0
63+
- --label=org.opencontainers.image.source=https://rackspace.com/
64+
- --label=org.opencontainers.image.authors=Rackspace
65+
docker_manifests:
66+
- name_template: ghcr.io/{{ .Env.GIT_REPO }}/{{ .ProjectName }}:{{ .Env.CUSTOM_TAG }}
67+
image_templates:
68+
- ghcr.io/{{ .Env.GIT_REPO }}/{{ .ProjectName }}:{{ .Env.CUSTOM_TAG }}-amd64
69+
- ghcr.io/{{ .Env.GIT_REPO }}/{{ .ProjectName }}:{{ .Env.CUSTOM_TAG }}-arm64
70+
- name_template: ghcr.io/{{ .Env.GIT_REPO }}/{{ .ProjectName }}:latest
71+
image_templates:
72+
- ghcr.io/{{ .Env.GIT_REPO }}/{{ .ProjectName }}:{{ .Env.CUSTOM_TAG }}-amd64
73+
- ghcr.io/{{ .Env.GIT_REPO }}/{{ .ProjectName }}:{{ .Env.CUSTOM_TAG }}-arm64
74+
75+
76+
signs:
77+
- cmd: cosign
78+
signature: "${artifact}.sig"
79+
certificate: "${artifact}.pem"
80+
output: true
81+
artifacts: checksum
82+
args:
83+
- sign-blob
84+
- "--oidc-provider=github-actions"
85+
- "--output-certificate=${certificate}"
86+
- "--output-signature=${signature}"
87+
- "${artifact}"
88+
- --yes
89+
90+
docker_signs:
91+
- cmd: cosign
92+
artifacts: manifests
93+
output: true
94+
args:
95+
- "sign"
96+
- "--oidc-provider=github-actions"
97+
- "${artifact}@${digest}"
98+
- --yes

go/nautobotop/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ Dockerfile.cross
1717

1818
# Go workspace file
1919
go.work
20+
vendor/
21+
dist/
2022

2123
# Kubernetes Generated files - skip generated files, except for vendored files
2224
!vendor/**/zz_generated.*

go/nautobotop/.goreleaser.yaml

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ before:
77

88
env:
99
- CUSTOM_TAG={{ .Env.CUSTOM_TAG }}
10+
- GIT_REPO={{ .Env.GIT_REPO }}
1011

1112
builds:
1213
- main: main.go
@@ -32,7 +33,7 @@ dockers:
3233
use: buildx
3334
dockerfile: .goreleaser.Dockerfile
3435
image_templates:
35-
- ghcr.io/rackerlabs/understack/{{ .ProjectName }}:{{ .Env.CUSTOM_TAG }}-amd64
36+
- ghcr.io/{{ .Env.GIT_REPO }}/{{ .ProjectName }}:{{ .Env.CUSTOM_TAG }}-amd64
3637
build_flag_templates:
3738
- --platform=linux/amd64
3839
- --label=org.opencontainers.image.version={{ .Env.CUSTOM_TAG }}
@@ -49,7 +50,7 @@ dockers:
4950
use: buildx
5051
dockerfile: .goreleaser.Dockerfile
5152
image_templates:
52-
- ghcr.io/rackerlabs/understack/{{ .ProjectName }}:{{ .Env.CUSTOM_TAG }}-arm64
53+
- ghcr.io/{{ .Env.GIT_REPO }}/{{ .ProjectName }}:{{ .Env.CUSTOM_TAG }}-arm64
5354
build_flag_templates:
5455
- --platform=linux/arm64
5556
- --label=org.opencontainers.image.version={{ .Env.CUSTOM_TAG }}
@@ -62,14 +63,14 @@ dockers:
6263
- --label=org.opencontainers.image.source=https://rackspace.com/
6364
- --label=org.opencontainers.image.authors=Rackspace
6465
docker_manifests:
65-
- name_template: ghcr.io/rackerlabs/understack/{{ .ProjectName }}:{{ .Env.CUSTOM_TAG }}
66+
- name_template: ghcr.io/{{ .Env.GIT_REPO }}/{{ .ProjectName }}:{{ .Env.CUSTOM_TAG }}
6667
image_templates:
67-
- ghcr.io/rackerlabs/understack/{{ .ProjectName }}:{{ .Env.CUSTOM_TAG }}-amd64
68-
- ghcr.io/rackerlabs/understack/{{ .ProjectName }}:{{ .Env.CUSTOM_TAG }}-arm64
69-
- name_template: ghcr.io/rackerlabs/understack/{{ .ProjectName }}:latest
68+
- ghcr.io/{{ .Env.GIT_REPO }}/{{ .ProjectName }}:{{ .Env.CUSTOM_TAG }}-amd64
69+
- ghcr.io/{{ .Env.GIT_REPO }}/{{ .ProjectName }}:{{ .Env.CUSTOM_TAG }}-arm64
70+
- name_template: ghcr.io/{{ .Env.GIT_REPO }}/{{ .ProjectName }}:latest
7071
image_templates:
71-
- ghcr.io/rackerlabs/understack/{{ .ProjectName }}:{{ .Env.CUSTOM_TAG }}-amd64
72-
- ghcr.io/rackerlabs/understack/{{ .ProjectName }}:{{ .Env.CUSTOM_TAG }}-arm64
72+
- ghcr.io/{{ .Env.GIT_REPO }}/{{ .ProjectName }}:{{ .Env.CUSTOM_TAG }}-amd64
73+
- ghcr.io/{{ .Env.GIT_REPO }}/{{ .ProjectName }}:{{ .Env.CUSTOM_TAG }}-arm64
7374

7475

7576
signs:

operators/rook/values-cluster.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ cephBlockPools:
4343
size: 2
4444
storageClass:
4545
enabled: false
46-
- name: ceph-blockpool-ecoded
46+
- name: ceph-blockpool-encoded
4747
# For caches and other unimportant data
4848
spec:
4949
failureDomain: host
@@ -52,7 +52,7 @@ cephBlockPools:
5252
dataChunks: 2
5353
storageClass:
5454
enabled: true
55-
name: ceph-block-ecoded
55+
name: ceph-block-encoded
5656
isDefault: false
5757
reclaimPolicy: Retain
5858
allowVolumeExpansion: true
@@ -66,7 +66,7 @@ cephBlockPools:
6666
csi.storage.k8s.io/controller-expand-secret-namespace: "{{ .Release.Namespace }}"
6767
csi.storage.k8s.io/node-stage-secret-name: rook-csi-rbd-node
6868
csi.storage.k8s.io/node-stage-secret-namespace: "{{ .Release.Namespace }}"
69-
dataPool: ceph-blockpool-ecoded
69+
dataPool: ceph-blockpool-encoded
7070
pool: replicated-metadata-pool
7171
- name: ceph-block-single
7272
# see https://github.com/rook/rook/blob/master/Documentation/CRDs/Block-Storage/ceph-block-pool-crd.md#spec for available configuration

0 commit comments

Comments
 (0)