File tree Expand file tree Collapse file tree 5 files changed +76
-185
lines changed Expand file tree Collapse file tree 5 files changed +76
-185
lines changed Load Diff This file was deleted.
Original file line number Diff line number Diff line change 1+ name : CI
2+
3+ on :
4+ push :
5+ branches :
6+ - main
7+ tags :
8+ - v*
9+ pull_request :
10+ branches :
11+ - main
12+ pull_request_target :
13+ types :
14+ - closed
15+
16+ env :
17+ REGISTRY : docker.io
18+ IMAGE_NAME : ${{ github.repository }}
19+
20+ jobs :
21+ test :
22+ runs-on : ubuntu-latest
23+ permissions :
24+ contents : read # for actions/checkout to fetch code
25+ steps :
26+ - name : Checkout
27+ uses : actions/checkout@v3
28+
29+ - name : Setup
30+ uses : actions/setup-go@v3
31+ with :
32+ go-version : 1.19.x
33+ cache : true
34+
35+ - name : Test
36+ run : make test
37+
38+ build :
39+ runs-on : ubuntu-latest
40+ permissions :
41+ contents : read # for actions/checkout to fetch code
42+ packages : write
43+ steps :
44+ - name : Checkout
45+ uses : actions/checkout@v3
46+ with :
47+ fetch-depth : 0 # for git describe
48+ ref : ${{ github.event.pull_request.head.sha || github.sha }}
49+
50+ - name : Publish | Login to Docker Hub
51+ uses : docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9
52+ with :
53+ registry : ${{ env.REGISTRY }}
54+ username : ${{ secrets.DOCKERHUB_USERNAME }}
55+ password : ${{ secrets.DOCKERHUB_TOKEN }}
56+
57+ - name : Extract metadata (tags, labels) for Docker
58+ id : meta
59+ uses : docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38
60+ with :
61+ images : ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
62+
63+ - name : Build and push Docker image
64+ uses : docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc
65+ with :
66+ context : .
67+ push : true
68+ tags : ${{ steps.meta.outputs.tags }}
69+ labels : ${{ steps.meta.outputs.labels }}
Load Diff This file was deleted.
Load Diff This file was deleted.
Original file line number Diff line number Diff line change 11# Build the manager binary
22FROM golang:1.19 as builder
3+ ARG TARGETOS
4+ ARG TARGETARCH
35
46WORKDIR /workspace
57# Copy the Go Modules manifests
@@ -15,7 +17,11 @@ COPY api/ api/
1517COPY controllers/ controllers/
1618
1719# Build
18- RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -a -o manager main.go
20+ # the GOARCH has not a default value to allow the binary be built according to the host where the command
21+ # was called. For example, if we call make docker-build in a local env which has the Apple Silicon M1 SO
22+ # the docker BUILDPLATFORM arg will be linux/arm64 when for Apple x86 it will be linux/amd64. Therefore,
23+ # by leaving it empty we can ensure that the container and binary shipped on it will have the same platform.
24+ RUN CGO_ENABLED=0 GOOS=${TARGETOS:-linux} GOARCH=${TARGETARCH} go build -a -o manager main.go
1925
2026# Use distroless as minimal base image to package the manager binary
2127# Refer to https://github.com/GoogleContainerTools/distroless for more details
You can’t perform that action at this time.
0 commit comments