Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NETOBSERV-849 Console plugin multi-arch builds (upstream) #298

Merged
merged 1 commit into from
May 11, 2023
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
2 changes: 1 addition & 1 deletion .github/workflows/pull_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
strategy:
matrix:
go: ['1.18','1.19']

steps:
- name: install make
run: sudo apt-get install make
Expand Down
25 changes: 8 additions & 17 deletions .github/workflows/push_image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ on:

env:
REGISTRY_USER: netobserv+github_ci
REGISTRY_PASSWORD: ${{ secrets.QUAY_SECRET }}
REGISTRY: quay.io/netobserv
REG_IMAGE: network-observability-console-plugin
REG_TAG: main
IMAGE: network-observability-console-plugin
ORG: netobserv
VERSION: main

jobs:
push-image:
Expand All @@ -26,23 +26,14 @@ jobs:
go-version: ${{ matrix.go }}
- name: checkout
uses: actions/checkout@v3
- name: build images
run: BASE_IMAGE="${{ env.REGISTRY }}/${{ env.REG_IMAGE }}" TAG="${{ env.REG_TAG }}" make build-ci-images
- name: podman login to quay.io
uses: redhat-actions/podman-login@v1
- name: docker login to quay.io
uses: docker/login-action@v2
with:
username: ${{ env.REGISTRY_USER }}
password: ${{ env.REGISTRY_PASSWORD }}
password: ${{ secrets.QUAY_SECRET }}
registry: quay.io
- name: get short sha
run: echo "short_sha=$(git rev-parse --short HEAD)" >> $GITHUB_ENV
- name: push to quay.io
id: push-to-quay
uses: redhat-actions/push-to-registry@v2
with:
image: ${{ env.REG_IMAGE }}
tags: ${{ env.REG_TAG }} ${{ env.short_sha }}
registry: ${{ env.REGISTRY }}
- name: build and push manifest with images
run: IMAGE_ORG=${{ env.ORG }} VERSION=${{ env.VERSION }} make ci
- name: print image url
run: echo "Image pushed to ${{ steps.push-to-quay.outputs.registry-paths }}"

Expand Down
21 changes: 9 additions & 12 deletions .github/workflows/push_image_pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ on:
env:
REGISTRY_USER: netobserv+github_ci
REGISTRY: quay.io/netobserv
REG_IMAGE: network-observability-console-plugin
IMAGE: network-observability-console-plugin
ORG: netobserv
VERSION: temp

jobs:
push-pr-image:
Expand All @@ -27,23 +29,18 @@ jobs:
uses: actions/checkout@v3
with:
ref: "refs/pull/${{ github.event.number }}/merge"
- name: build images
run: BASE_IMAGE="${{ env.REGISTRY }}/${{ env.REG_IMAGE }}" TAG=temp make build-ci-images
- name: podman login to quay.io
uses: redhat-actions/podman-login@v1
- name: docker login to quay.io
uses: docker/login-action@v2
with:
username: ${{ env.REGISTRY_USER }}
password: ${{ secrets.QUAY_SECRET }}
registry: quay.io
- name: get short sha
run: echo "short_sha=$(git rev-parse --short HEAD)" >> $GITHUB_ENV
- name: push to quay.io
id: push-to-quay
uses: redhat-actions/push-to-registry@v2
with:
image: ${{ env.REG_IMAGE }}
tags: ${{ env.short_sha }}
registry: ${{ env.REGISTRY }}
- name: build and push images
run: IMAGE_ORG=${{ env.ORG }} IMAGE=${{ env.REGISTRY }}/${{ env.IMAGE }}:${{ env.short_sha }} make images
- name: build and push manifest
run: IMAGE_ORG=${{ env.ORG }} VERSION=${{ env.VERSION }} make ci-manifest
- uses: actions/github-script@v6
with:
github-token: ${{secrets.GITHUB_TOKEN}}
Expand Down
15 changes: 4 additions & 11 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,20 +36,13 @@ jobs:
uses: actions/setup-go@v3
with:
go-version: ${{ matrix.go }}
- name: build images
run: IMAGE="quay.io/netobserv/${{ env.IMAGE }}:${{ env.tag }}" make image
- name: podman login to quay.io
uses: redhat-actions/podman-login@v1
- name: docker login to quay.io
uses: docker/login-action@v2
with:
username: ${{ env.REGISTRY_USER }}
password: ${{ env.REGISTRY_PASSWORD }}
registry: quay.io
- name: push to quay.io
id: push-to-quay
uses: redhat-actions/push-to-registry@v2
with:
image: ${{ env.IMAGE }}
tags: ${{ env.tag }}
registry: ${{ env.REGISTRY }}
- name: build and push images
run: OCI_BIN=docker IMAGE="quay.io/netobserv/${{ env.IMAGE }}:${{ env.tag }}" make images
- name: print image url
run: echo "Image pushed to ${{ steps.push-to-quay.outputs.registry-paths }}"
56 changes: 56 additions & 0 deletions .mk/shortcuts.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
##@ shortcuts helpers
.PHONY: fmt
fmt: fmt-backend fmt-frontend ## Fmt all

.PHONY: lint
lint: lint-backend lint-frontend ## Lint all

.PHONY: test
test: test-backend test-frontend ## Test all

.PHONY: i18n
i18n: ## Run frontend i18n
@echo "### generating frontend locales"
cd web && npm run i18n

.PHONY: build-frontend
build-frontend: install-frontend fmt-frontend just-build-frontend ## Run npm install, format and build frontend

.PHONY: build
build: build-backend build-frontend ## Build all

.PHONY: build-standalone
build-standalone: build-backend build-frontend-standalone ## Build all as standalone

.PHONY: frontend
frontend: build-frontend lint-frontend test-frontend ## Build lint and test frontend

.PHONY: backend
backend: build-backend lint-backend test-backend ## Build lint and test backend

.PHONY: build-image
build-image: image-build ## Build MULTIARCH_TARGETS images

.PHONY: push-image
push-image: image-push ## Push MULTIARCH_TARGETS images

.PHONY: build-manifest
build-manifest: manifest-build ## Build MULTIARCH_TARGETS manifest

.PHONY: push-manifest
push-manifest: manifest-push ## Push MULTIARCH_TARGETS manifest

.PHONY: images
images: image-build image-push manifest-build manifest-push ## Build and push MULTIARCH_TARGETS images and related manifest

.PHONY: build-ci-manifest
build-ci-manifest: ci-manifest-build ## Build CI manifest

.PHONY: push-ci-manifest
push-ci-manifest: ci-manifest-push ## Push CI manifest

.PHONY: ci-manifest
ci-manifest: ci-manifest-build ci-manifest-push ## Build and push CI manifest

.PHONY: ci
ci: images ci-manifest ## Build and push CI images and manifest
32 changes: 21 additions & 11 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,31 +1,41 @@
FROM registry.access.redhat.com/ubi9/nodejs-16:1 as web-builder

# We do not use --platform feature to auto fill this ARG because of incompatibility between podman and docker
ARG TARGETPLATFORM=linux/amd64
ARG BUILDPLATFORM=linux/amd64
FROM --platform=$BUILDPLATFORM docker.io/library/node:16-alpine as web-builder
USER node

ARG TARGETPLATFORM
ARG TARGETARCH=amd64
WORKDIR /opt/app-root

COPY --chown=default Makefile Makefile
COPY --chown=default web/package.json web/package.json
COPY --chown=default web/package-lock.json web/package-lock.json
RUN NPM_INSTALL=ci make install-frontend
COPY --chown=node Makefile Makefile
COPY --chown=node web/package.json web/package.json
COPY --chown=node web/package-lock.json web/package-lock.json
RUN cd web && npm ci

COPY --chown=default web web
COPY --chown=node web web
COPY mocks mocks
RUN make fmt-frontend just-build-frontend
RUN cd web && npm run format-all
RUN cd web && npm run build

FROM docker.io/library/golang:1.19 as go-builder
FROM --platform=$BUILDPLATFORM docker.io/library/golang:1.19 as go-builder

ARG TARGETPLATFORM
ARG TARGETARCH=amd64
WORKDIR /opt/app-root

COPY .git .git
COPY go.mod go.mod
COPY go.sum go.sum
COPY vendor/ vendor/
COPY Makefile Makefile
COPY .mk/ .mk/
COPY cmd/ cmd/
COPY pkg/ pkg/

RUN make build-backend
RUN CGO_ENABLED=0 GOARCH=$TARGETARCH make build-backend

FROM registry.access.redhat.com/ubi9/ubi-minimal:9.1
FROM --platform=$TARGETPLATFORM registry.access.redhat.com/ubi9/ubi-minimal:9.1

COPY --from=web-builder /opt/app-root/web/dist ./web/dist
COPY --from=go-builder /opt/app-root/plugin-backend ./
Expand Down
Loading