Skip to content
This repository was archived by the owner on May 24, 2023. It is now read-only.

Commit f1a4f88

Browse files
committed
Add builds for arm64, s390x and ppc64le
1 parent b6f3902 commit f1a4f88

File tree

5 files changed

+89
-14
lines changed

5 files changed

+89
-14
lines changed

.github/workflows/ci.yml

+48-10
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ on:
2323
- '**.md'
2424

2525
env:
26-
DOCKER_BUILDKIT: 1
26+
platforms: "linux/amd64,linux/arm64,linux/ppc64le,linux/s390x"
2727

2828
concurrency:
2929
group: ${{ github.ref_name }}-ci
@@ -55,17 +55,21 @@ jobs:
5555
steps:
5656
- name: Checkout Repository
5757
uses: actions/checkout@v2
58+
- name: Cache Go build
59+
uses: actions/cache@v2
60+
with:
61+
path: |
62+
~/.cache/go-build
63+
~/go/pkg/mod
64+
key: ${{ runner.os }}-go-local-build-${{ hashFiles('**/go.sum') }}
65+
restore-keys: |
66+
${{ runner.os }}-go-local-build-
5867
- name: Setup Golang Environment
5968
uses: actions/setup-go@v2
6069
with:
6170
go-version: ${{ needs.vars.outputs.go_version }}
6271
- name: Build Binary
6372
run: make build
64-
- name: Cache Artifacts
65-
uses: actions/cache@v2
66-
with:
67-
path: ${{ github.workspace }}/bin/manager
68-
key: nginx-ingress-operator-${{ github.run_id }}-${{ github.run_number }}
6973

7074
unit-tests:
7175
name: Unit Tests
@@ -78,27 +82,59 @@ jobs:
7882
uses: actions/setup-go@v2
7983
with:
8084
go-version: ${{ needs.vars.outputs.go_version }}
85+
- name: Cache Go tests
86+
uses: actions/cache@v2
87+
with:
88+
path: |
89+
~/.cache/go-build
90+
~/go/pkg/mod
91+
key: ${{ runner.os }}-go-tests-${{ hashFiles('**/go.sum') }}
92+
restore-keys: |
93+
${{ runner.os }}-go-tests-
8194
- name: Run Tests
8295
run: make test
8396

8497
build:
8598
name: Build Image
8699
runs-on: ubuntu-20.04
87-
needs: [binary, unit-tests]
100+
needs: [binary, vars, unit-tests]
88101
steps:
89102
- name: Checkout Repository
90103
uses: actions/checkout@v2
91-
- name: Fetch Cached Artifacts
104+
with:
105+
fetch-depth: 0
106+
- name: Cache Go build
92107
uses: actions/cache@v2
93108
with:
94-
path: ${{ github.workspace }}/bin/manager
95-
key: nginx-ingress-operator-${{ github.run_id }}-${{ github.run_number }}
109+
path: |
110+
~/.cache/go-build
111+
~/go/pkg/mod
112+
key: ${{ runner.os }}-go-build-${{ hashFiles('**/go.sum') }}
113+
restore-keys: |
114+
${{ runner.os }}-go-build-
115+
- name: Setup Golang Environment
116+
uses: actions/setup-go@v2
117+
with:
118+
go-version: ${{ needs.vars.outputs.go_version }}
119+
- name: Build binaries
120+
uses: goreleaser/goreleaser-action@v2
121+
with:
122+
version: latest
123+
args: ${{ !startsWith(github.ref, 'refs/tags/') && 'build --snapshot' || 'release' }} ${{ github.event_name == 'pull_request' && '--single-target' || '' }} --rm-dist
124+
env:
125+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
126+
GOPATH: ${{ needs.check.outputs.go_path }}
96127
- name: DockerHub Login
97128
uses: docker/login-action@v1
98129
with:
99130
username: ${{ secrets.DOCKER_USERNAME }}
100131
password: ${{ secrets.DOCKER_PASSWORD }}
101132
if: github.event_name != 'pull_request'
133+
- name: Setup QEMU
134+
uses: docker/setup-qemu-action@v1
135+
with:
136+
platforms: arm64,ppc64le,s390x
137+
if: github.event_name != 'pull_request'
102138
- name: Docker Buildx
103139
uses: docker/setup-buildx-action@v1
104140
- name: Docker meta
@@ -120,8 +156,10 @@ jobs:
120156
context: '.'
121157
cache-from: type=gha
122158
cache-to: type=gha,mode=max
159+
target: goreleaser
123160
tags: ${{ steps.meta.outputs.tags }}
124161
labels: ${{ steps.meta.outputs.labels }}
162+
platforms: ${{ github.event_name != 'pull_request' && env.platforms || '' }}
125163
load: ${{ github.event_name == 'pull_request' }}
126164
push: ${{ github.event_name != 'pull_request' }}
127165
pull: true

.gitignore

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
# Binaries for programs and plugins
32
*.exe
43
*.exe~
@@ -24,3 +23,5 @@ testbin/*
2423
*.swo
2524
*~
2625
.vscode/
26+
27+
dist

.goreleaser.yml

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
env:
2+
- CGO_ENABLED=0
3+
builds:
4+
- id: nginx-ingress-operator
5+
goos:
6+
- linux
7+
goarch:
8+
- amd64
9+
- arm64
10+
- ppc64le
11+
- s390x
12+
flags:
13+
- -trimpath
14+
gcflags:
15+
- all=-trimpath={{.Env.GOPATH}}
16+
asmflags:
17+
- all=-trimpath={{.Env.GOPATH}}
18+
binary: manager
19+
20+
archives:
21+
- format: binary
22+
changelog:
23+
skip: true

Dockerfile

+15-2
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,9 @@ COPY controllers/ controllers/
1818
# Build
1919
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags "-s -w -X main.version=${VERSION}" -a -o manager main.go
2020

21-
FROM registry.access.redhat.com/ubi8/ubi-minimal:latest
21+
FROM registry.access.redhat.com/ubi8/ubi-minimal:latest as base
2222
ARG VERSION
2323
WORKDIR /
24-
COPY --from=builder /workspace/manager .
2524
COPY config/crd/kic ./config/crd/kic
2625
COPY LICENSE /licenses/
2726

@@ -35,3 +34,17 @@ LABEL name="NGINX Ingress Operator" \
3534
ENTRYPOINT ["/manager"]
3635

3736
USER 1001
37+
38+
FROM base as goreleaser
39+
ARG TARGETARCH
40+
ARG TARGETVARIANT
41+
42+
LABEL org.nginx.kic.image.build.version="goreleaser"
43+
44+
COPY ./dist/nginx-ingress-operator_linux_$TARGETARCH/manager /
45+
46+
FROM base as local
47+
48+
LABEL org.nginx.kic.image.build.version="local"
49+
50+
COPY --from=builder /workspace/manager .

Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ run: manifests generate fmt vet ## Run a controller from your host.
106106
go run -ldflags "-X main.version=${VERSION}" ./main.go $(ARGS)
107107

108108
docker-build: test ## Build docker image with the manager.
109-
docker build -t ${IMG} -f ${DOCKERFILE} . --build-arg VERSION=${VERSION}
109+
docker build -t ${IMG} -f ${DOCKERFILE} . --build-arg VERSION=${VERSION} --target local
110110

111111
docker-push: ## Push docker image with the manager.
112112
docker push ${IMG}

0 commit comments

Comments
 (0)