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

Add builds for arm64, s390x and ppc64le #193

Merged
merged 2 commits into from
Jan 12, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 48 additions & 10 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ on:
- '**.md'

env:
DOCKER_BUILDKIT: 1
platforms: "linux/amd64,linux/arm64,linux/ppc64le,linux/s390x"

concurrency:
group: ${{ github.ref_name }}-ci
Expand Down Expand Up @@ -55,17 +55,21 @@ jobs:
steps:
- name: Checkout Repository
uses: actions/checkout@v2
- name: Cache Go build
uses: actions/cache@v2
with:
path: |
~/.cache/go-build
~/go/pkg/mod
key: ${{ runner.os }}-go-local-build-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-local-build-
- name: Setup Golang Environment
uses: actions/setup-go@v2
with:
go-version: ${{ needs.vars.outputs.go_version }}
- name: Build Binary
run: make build
- name: Cache Artifacts
uses: actions/cache@v2
with:
path: ${{ github.workspace }}/bin/manager
key: nginx-ingress-operator-${{ github.run_id }}-${{ github.run_number }}

unit-tests:
name: Unit Tests
Expand All @@ -78,27 +82,59 @@ jobs:
uses: actions/setup-go@v2
with:
go-version: ${{ needs.vars.outputs.go_version }}
- name: Cache Go tests
uses: actions/cache@v2
with:
path: |
~/.cache/go-build
~/go/pkg/mod
key: ${{ runner.os }}-go-tests-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-tests-
- name: Run Tests
run: make test

build:
name: Build Image
runs-on: ubuntu-20.04
needs: [binary, unit-tests]
needs: [binary, vars, unit-tests]
steps:
- name: Checkout Repository
uses: actions/checkout@v2
- name: Fetch Cached Artifacts
with:
fetch-depth: 0
- name: Cache Go build
uses: actions/cache@v2
with:
path: ${{ github.workspace }}/bin/manager
key: nginx-ingress-operator-${{ github.run_id }}-${{ github.run_number }}
path: |
~/.cache/go-build
~/go/pkg/mod
key: ${{ runner.os }}-go-build-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-build-
- name: Setup Golang Environment
uses: actions/setup-go@v2
with:
go-version: ${{ needs.vars.outputs.go_version }}
- name: Build binaries
uses: goreleaser/goreleaser-action@v2
with:
version: latest
args: ${{ !startsWith(github.ref, 'refs/tags/') && 'build --snapshot' || 'release' }} ${{ github.event_name == 'pull_request' && '--single-target' || '' }} --rm-dist
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GOPATH: ${{ needs.check.outputs.go_path }}
- name: DockerHub Login
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
if: github.event_name != 'pull_request'
- name: Setup QEMU
uses: docker/setup-qemu-action@v1
with:
platforms: arm64,ppc64le,s390x
if: github.event_name != 'pull_request'
- name: Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Docker meta
Expand All @@ -120,8 +156,10 @@ jobs:
context: '.'
cache-from: type=gha
cache-to: type=gha,mode=max
target: goreleaser
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
platforms: ${{ github.event_name != 'pull_request' && env.platforms || '' }}
load: ${{ github.event_name == 'pull_request' }}
push: ${{ github.event_name != 'pull_request' }}
pull: true
Expand Down
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

# Binaries for programs and plugins
*.exe
*.exe~
Expand All @@ -24,3 +23,5 @@ testbin/*
*.swo
*~
.vscode/

dist
23 changes: 23 additions & 0 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
env:
- CGO_ENABLED=0
builds:
- id: nginx-ingress-operator
goos:
- linux
goarch:
- amd64
- arm64
- ppc64le
- s390x
flags:
- -trimpath
gcflags:
- all=-trimpath={{.Env.GOPATH}}
asmflags:
- all=-trimpath={{.Env.GOPATH}}
binary: manager

archives:
- format: binary
changelog:
skip: true
17 changes: 15 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,9 @@ COPY controllers/ controllers/
# Build
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags "-s -w -X main.version=${VERSION}" -a -o manager main.go

FROM registry.access.redhat.com/ubi8/ubi-minimal:latest
FROM registry.access.redhat.com/ubi8/ubi-minimal:latest as base
ARG VERSION
WORKDIR /
COPY --from=builder /workspace/manager .
COPY config/crd/kic ./config/crd/kic
COPY LICENSE /licenses/

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

USER 1001

FROM base as goreleaser
ARG TARGETARCH
ARG TARGETVARIANT

LABEL org.nginx.kic.image.build.version="goreleaser"

COPY ./dist/nginx-ingress-operator_linux_$TARGETARCH/manager /

FROM base as local

LABEL org.nginx.kic.image.build.version="local"

COPY --from=builder /workspace/manager .
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ run: manifests generate fmt vet ## Run a controller from your host.
go run -ldflags "-X main.version=${VERSION}" ./main.go $(ARGS)

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

docker-push: ## Push docker image with the manager.
docker push ${IMG}
Expand Down