Skip to content

Commit df40f17

Browse files
committed
add release workflow and dockerfile
1 parent e3dabc0 commit df40f17

File tree

5 files changed

+74
-2
lines changed

5 files changed

+74
-2
lines changed

.dockerignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
*
2+
!cmd
3+
!go.mod
4+
!go.sum

.github/workflows/build.yaml

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
name: Build and push Docker image
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*'
7+
8+
env:
9+
REGISTRY: ghcr.io
10+
11+
jobs:
12+
build:
13+
runs-on: ubuntu-22.04
14+
15+
steps:
16+
- name: Checkout repository
17+
uses: actions/checkout@v4
18+
19+
- name: Set up QEMU
20+
uses: docker/setup-qemu-action@v3
21+
22+
- name: Set up Docker Buildx
23+
uses: docker/setup-buildx-action@v3
24+
25+
- name: Login to GitHub Container Registry
26+
uses: docker/login-action@v3
27+
with:
28+
registry: ${{ env.REGISTRY }}
29+
username: ${{ github.actor }}
30+
password: ${{ secrets.GITHUB_TOKEN }}
31+
32+
- name: Extract metadata (tags, labels) for Docker
33+
id: meta
34+
uses: docker/metadata-action@v5
35+
with:
36+
images: ${{ steps.base_image_name.outputs.image_name }}
37+
tags: |
38+
type=raw,value=latest,enable={{is_default_branch}}
39+
type=raw,value={{branch}}-{{sha}}-{{date 'X'}},enable=${{ startsWith(github.ref, 'refs/heads') }}
40+
type=semver,pattern={{version}},prefix=v
41+
type=semver,pattern={{major}}.{{minor}},prefix=v
42+
43+
- name: Build and push image
44+
uses: docker/build-push-action@v5
45+
with:
46+
tags: ${{ steps.meta.outputs.tags }}
47+
labels: ${{ steps.meta.outputs.labels }}
48+
platforms: linux/amd64,linux/arm64
49+
cache-from: type=gha
50+
cache-to: type=gha,mode=max
51+
push: true

Dockerfile

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
FROM --platform=${BUILDPLATFORM:-linux/amd64} golang:1.21 as builder
2+
3+
ARG TARGETPLATFORM
4+
ARG BUILDPLATFORM
5+
ARG TARGETOS
6+
ARG TARGETARCH
7+
8+
WORKDIR /app/
9+
ADD . .
10+
RUN CGO_ENABLED=0 GOOS=${TARGETOS} GOARCH=${TARGETARCH} go build -ldflags="-w -s" -o flux-webhook-authreconciler ./cmd
11+
12+
FROM --platform=${TARGETPLATFORM:-linux/amd64} scratch
13+
WORKDIR /app/
14+
COPY --from=builder /app/flux-webhook-authreconciler /app/flux-webhook-authreconciler
15+
ENTRYPOINT ["/app/flux-webhook-authreconciler"]

go.mod

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,10 @@ require (
66
github.com/fluxcd/pkg/apis/meta v1.1.2
77
github.com/fluxcd/source-controller/api v1.1.0
88
github.com/go-playground/validator/v10 v10.15.4
9+
github.com/google/uuid v1.3.1
910
github.com/gorilla/websocket v1.5.0
1011
github.com/prometheus/client_golang v1.16.0
12+
go.uber.org/zap v1.26.0
1113
gopkg.in/yaml.v3 v3.0.1
1214
k8s.io/apimachinery v0.28.2
1315
k8s.io/client-go v0.28.2
@@ -32,7 +34,6 @@ require (
3234
github.com/google/go-cmp v0.5.9 // indirect
3335
github.com/google/gofuzz v1.2.0 // indirect
3436
github.com/google/pprof v0.0.0-20221103000818-d260c55eee4c // indirect
35-
github.com/google/uuid v1.3.1 // indirect
3637
github.com/imdario/mergo v0.3.15 // indirect
3738
github.com/josharian/intern v1.0.0 // indirect
3839
github.com/json-iterator/go v1.1.12 // indirect
@@ -50,7 +51,6 @@ require (
5051
github.com/spf13/pflag v1.0.5 // indirect
5152
github.com/stretchr/testify v1.8.4 // indirect
5253
go.uber.org/multierr v1.11.0 // indirect
53-
go.uber.org/zap v1.26.0 // indirect
5454
golang.org/x/crypto v0.12.0 // indirect
5555
golang.org/x/net v0.14.0 // indirect
5656
golang.org/x/oauth2 v0.11.0 // indirect

go.sum

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,8 @@ github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcU
115115
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
116116
github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
117117
github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
118+
go.uber.org/goleak v1.2.1 h1:NBol2c7O1ZokfZ0LEU9K6Whx/KnwvepVetCUhtKja4A=
119+
go.uber.org/goleak v1.2.1/go.mod h1:qlT2yGI9QafXHhZZLxlSuNsMw3FFLxBr+tBRlmO1xH4=
118120
go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0=
119121
go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y=
120122
go.uber.org/zap v1.26.0 h1:sI7k6L95XOKS281NhVKOFCUNIvv9e0w4BF8N3u+tCRo=

0 commit comments

Comments
 (0)