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

Issue 1068 image multi registry #3

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
61 commits
Select commit Hold shift + click to select a range
6a7d652
Check if image pushes to GHCR
sarathchandra24 Mar 3, 2024
ca60ff4
Fix action execution strategy
sarathchandra24 Mar 3, 2024
26c2d3c
scan images skeleton
sarathchandra24 Mar 3, 2024
fa0d8e0
check status
sarathchandra24 Mar 3, 2024
4e14617
Fix versioning
sarathchandra24 Mar 3, 2024
aba824c
add scanning feature
sarathchandra24 Mar 3, 2024
bb18188
clone to docker hub
sarathchandra24 Mar 3, 2024
cd9276d
fix filex
sarathchandra24 Mar 3, 2024
6312669
test runner
sarathchandra24 Mar 3, 2024
e0c4f47
fix image name to lowercase
sarathchandra24 Mar 3, 2024
a23f76e
fix registry addition
sarathchandra24 Mar 3, 2024
b63d55e
change secret value
sarathchandra24 Mar 3, 2024
58fd9da
variable creation
sarathchandra24 Mar 3, 2024
7f4a165
fix traces
sarathchandra24 Mar 3, 2024
c38c1bd
check outs
sarathchandra24 Mar 3, 2024
1eb0412
check logs
sarathchandra24 Mar 3, 2024
a2c70be
change registry info
sarathchandra24 Mar 3, 2024
68000b1
change username
sarathchandra24 Mar 3, 2024
1310ba5
specify version of docker image
sarathchandra24 Mar 3, 2024
69b0bbe
fix version in cloning
sarathchandra24 Mar 3, 2024
9a4234a
check credentials
sarathchandra24 Mar 3, 2024
8b70b31
check revisions
sarathchandra24 Mar 3, 2024
6410912
check copy
sarathchandra24 Mar 3, 2024
41e5bf7
change permissions
sarathchandra24 Mar 3, 2024
d223c8a
set permissions
sarathchandra24 Mar 3, 2024
9c29997
permissions change
sarathchandra24 Mar 3, 2024
7c3f404
add skopeo to clone
sarathchandra24 Mar 4, 2024
0d503f6
add clone images wflow
sarathchandra24 Mar 4, 2024
953d658
Merge branch 'fluent:master' into ISSUE-1068_image_multi_registry
sarathchandra24 Mar 4, 2024
57359c7
clone image action fix
sarathchandra24 Mar 4, 2024
b7c7497
use native skoepo instead of docker image
sarathchandra24 Mar 4, 2024
f54a40c
Clone image copy
sarathchandra24 Mar 4, 2024
885b94f
docker check auth
sarathchandra24 Mar 4, 2024
9201ac5
clone image fix
sarathchandra24 Mar 4, 2024
96d6150
remove no image credentials
sarathchandra24 Mar 4, 2024
9cee86f
check entire workflow
sarathchandra24 Mar 4, 2024
ec69d85
action lining fix
sarathchandra24 Mar 4, 2024
2fe2b13
don't clone on PR
sarathchandra24 Mar 4, 2024
efc97a1
fix image names
sarathchandra24 Mar 4, 2024
0bccca8
build fluent bit images action
sarathchandra24 Mar 4, 2024
9fa524c
Build FluentBit Images
sarathchandra24 Mar 4, 2024
a73c3ee
Fix dockerfile location
sarathchandra24 Mar 4, 2024
3cc020d
fix fb debug image tags
sarathchandra24 Mar 4, 2024
ad653af
fix debug image tag
sarathchandra24 Mar 4, 2024
28b7df8
fix debug image tags
sarathchandra24 Mar 4, 2024
6f104f3
check pattern
sarathchandra24 Mar 4, 2024
c256e6b
fix tags
sarathchandra24 Mar 4, 2024
79b545b
fix
sarathchandra24 Mar 4, 2024
9b706e8
ewstep to change tags
sarathchandra24 Mar 4, 2024
03510af
version debug fix
sarathchandra24 Mar 4, 2024
3c13449
fix debug image changes
sarathchandra24 Mar 4, 2024
8a2769f
fix image names
sarathchandra24 Mar 4, 2024
50b456f
fluent bit build only debug
sarathchandra24 Mar 4, 2024
6eb7c34
Fix suffix tag
sarathchandra24 Mar 4, 2024
0b33c20
fix image tags
sarathchandra24 Mar 4, 2024
9fef303
fix entire pipeline
sarathchandra24 Mar 4, 2024
606f564
change docker build version
sarathchandra24 Mar 4, 2024
d71fe92
remove branch based image build
sarathchandra24 Mar 4, 2024
75fb7d9
fix versioning name
sarathchandra24 Mar 4, 2024
1b49803
globally disable latest
sarathchandra24 Mar 4, 2024
d9fe953
Change docker repo
sarathchandra24 Mar 4, 2024
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
197 changes: 187 additions & 10 deletions .github/workflows/build-fb-image.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,89 @@ on:
- "cmd/fluent-watcher/fluentbit/**"
- "cmd/fluent-watcher/hooks/**"
- "pkg/filenotify/**"
pull_request:
branches:
- "master"

env:
FB_IMG: 'kubesphere/fluent-bit:v2.2.2'
FB_IMG_DEBUG: 'kubesphere/fluent-bit:v2.2.2-debug'
DOCKER_REPO: 'kubesphere'
DOCKER_IMAGE: 'fluent-bit'
GITHUB_IMAGE: '${{ github.repository }}/fluent-bit'

jobs:
build:
build-prod-image-metadata:
runs-on: ubuntu-latest
name: Build prod image metadata
outputs:
IMG_NAME: ${{ steps.set-outputs.outputs.IMAGE_NAME }}
DOCKER_IMG_NAME: ${{ steps.set-outputs.outputs.DOCKER_IMG_NAME }}
version: ${{ steps.image-metadata.outputs.version }}
tags: ${{ steps.image-metadata.outputs.tags }}
labels: ${{ steps.image-metadata.outputs.labels }}
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: docker metadata
id: image-metadata
uses: docker/metadata-action@v5
with:
images: "ghcr.io/${{ env.GITHUB_IMAGE }}"
tags: |
raw,latest
type=ref,event=branch
type=ref,event=pr
type=ref,event=tag
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}

- name: Set outputs
id: set-outputs
run: |
echo "IMAGE_NAME=${{ env.GITHUB_IMAGE }}" >> $GITHUB_OUTPUT
echo "DOCKER_IMG_NAME=${{env.DOCKER_REPO}}/${{ env.DOCKER_IMAGE }}" >> $GITHUB_OUTPUT

build-debug-image-metadata:
runs-on: ubuntu-latest
name: Build debug image metadata
outputs:
IMG_NAME: ${{ steps.set-outputs.outputs.IMAGE_NAME }}
DOCKER_IMG_NAME: ${{ steps.set-outputs.outputs.DOCKER_IMG_NAME }}
version: ${{ steps.image-metadata.outputs.version }}
tags: ${{ steps.image-metadata.outputs.tags }}
labels: ${{ steps.image-metadata.outputs.labels }}
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: docker metadata
id: image-metadata
uses: docker/metadata-action@v5
with:
images: "ghcr.io/${{ env.GITHUB_IMAGE }}"
flavor: |
latest=false
suffix=-debug
tags: |
raw,latest
type=ref,event=branch
type=ref,event=pr
type=ref,event=tag
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}

- name: Set outputs
id: set-outputs
run: |
echo "IMAGE_NAME=${{ env.GITHUB_IMAGE }}" >> $GITHUB_OUTPUT
echo "DOCKER_IMG_NAME=${{env.DOCKER_REPO}}/${{ env.DOCKER_IMAGE }}" >> $GITHUB_OUTPUT

build-FluentBit-prod-image:
needs:
- build-prod-image-metadata
runs-on: ubuntu-latest
timeout-minutes: 30
name: Build Image for Fluent Bit
name: Build Fluent Bit prod image
steps:
- name: Install Go
uses: actions/setup-go@v4
Expand All @@ -37,17 +110,121 @@ jobs:
with:
fetch-depth: 0

- name: Login to Docker Hub
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
username: ${{ secrets.REGISTRY_USER }}
password: ${{ secrets.REGISTRY_PASSWORD }}
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v3

- name: Build and Push Image for Fluent Bit
run: |
make build-fb -e FB_IMG=${{ env.FB_IMG }}
make build-fb-debug -e FB_IMG_DEBUG=${{ env.FB_IMG_DEBUG }}
id: docker-build
uses: docker/build-push-action@v5
with:
context: .
file: ./cmd/fluent-watcher/fluentbit/Dockerfile
push: true
platforms: linux/amd64,linux/arm64
tags: ${{ needs.build-prod-image-metadata.outputs.tags }}
labels: ${{ needs.build-prod-image-metadata.outputs.labels }}

build-FluentBit-debug-image:
needs:
- build-debug-image-metadata
runs-on: ubuntu-latest
timeout-minutes: 30
name: Build Fluent Bit debug image
steps:
- name: Install Go
uses: actions/setup-go@v4
with:
go-version: 1.21

- uses: actions/cache@v3
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}

- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v3

- name: Build and Push Fluent Bit Debug Image
id: docker-build-debug
uses: docker/build-push-action@v5
with:
context: .
file: ./cmd/fluent-watcher/fluentbit/Dockerfile.debug
push: true
platforms: linux/amd64,linux/arm64
tags: ${{ needs.build-debug-image-metadata.outputs.tags }}
labels: ${{ needs.build-debug-image-metadata.outputs.labels }}

scan-FluentBit-image:
name: Scan prod image
needs:
- build-prod-image-metadata
- build-FluentBit-prod-image
uses: ./.github/workflows/scan-docker-image-action.yaml
with:
source_image: "${{ needs.build-prod-image-metadata.outputs.IMG_NAME }}:${{ needs.build-prod-image-metadata.outputs.version }}"
source_registry: ghcr.io
platforms: "['linux/arm64', 'linux/amd64']"
secrets:
registry_username: ${{ github.actor }}
registry_password: ${{ secrets.GITHUB_TOKEN }}

release-prod-image-to-docker-hub:
if: ${{ github.event_name != 'pull_request' }}
name: Release prod image to Docker Hub
uses: ./.github/workflows/clone-docker-image-action.yaml
needs:
- build-FluentBit-prod-image
- scan-FluentBit-image
- build-prod-image-metadata
with:
source_image: "${{ needs.build-prod-image-metadata.outputs.IMG_NAME }}:${{ needs.build-prod-image-metadata.outputs.version }}"
source_registry: ghcr.io
target_image: "${{ needs.build-prod-image-metadata.outputs.DOCKER_IMG_NAME }}:${{ needs.build-prod-image-metadata.outputs.version }}"
target_registry: docker.io
platforms: "['linux/arm64', 'linux/amd64']"
secrets:
source_registry_username: ${{ github.actor }}
source_registry_token: ${{ secrets.GITHUB_TOKEN }}
target_registry_username: ${{ secrets.REGISTRY_USER }}
target_registry_token: ${{ secrets.REGISTRY_PASSWORD }}

release-debug-image-to-docker-hub:
if: ${{ github.event_name != 'pull_request' }}
name: Release debug image to Docker Hub
uses: ./.github/workflows/clone-docker-image-action.yaml
needs:
- build-FluentBit-debug-image
- build-debug-image-metadata
with:
source_image: "${{ needs.build-debug-image-metadata.outputs.IMG_NAME }}:${{ needs.build-debug-image-metadata.outputs.version }}"
source_registry: ghcr.io
target_image: "${{ needs.build-debug-image-metadata.outputs.DOCKER_IMG_NAME }}:${{ needs.build-debug-image-metadata.outputs.version }}"
target_registry: docker.io
platforms: "['linux/arm64', 'linux/amd64']"
secrets:
source_registry_username: ${{ github.actor }}
source_registry_token: ${{ secrets.GITHUB_TOKEN }}
target_registry_username: ${{ secrets.REGISTRY_USER }}
target_registry_token: ${{ secrets.REGISTRY_PASSWORD }}
125 changes: 102 additions & 23 deletions .github/workflows/build-op-image.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@ name: Building Fluent Operator image
on:
push:
branches:
- 'master'
- "master"
- "ISSUE-*"
tags:
- 'v*'
- "v*"
paths:
- ".github/workflows/build-op-image.yaml"
- ".github/workflows/clone-docker-image-action.yaml"
- "apis/**"
- "cmd/fluent-manager/**"
- "controllers/**"
Expand All @@ -18,41 +20,118 @@ on:
- "pkg/fluentd/utils/**"
- "Makefile"

pull_request:
branches:
- "master"

env:
REGISTRY_REPO: 'kubesphere'
DOCKER_REPO: "kubesphere"
DOCKER_IMAGE: "fluent-operator"
GITHUB_IMAGE: "${{ github.repository }}/fluent-operator"

permissions:
contents: read
packages: write

jobs:
operator-build:
build-image-metadata:
runs-on: ubuntu-latest
timeout-minutes: 30
name: Build Image for Fluent Operator
name: Build Image Metadata
outputs:
IMG_NAME: ${{ steps.set-outputs.outputs.IMAGE_NAME }}
DOCKER_IMG_NAME: ${{ steps.set-outputs.outputs.DOCKER_IMG_NAME }}
version: ${{ steps.image-metadata.outputs.version }}
tags: ${{ steps.image-metadata.outputs.tags }}
labels: ${{ steps.image-metadata.outputs.labels }}

steps:
- name: Install Go
uses: actions/setup-go@v4
- name: Checkout code
uses: actions/checkout@v4

- name: docker metadata
id: image-metadata
uses: docker/metadata-action@v5
with:
go-version: 1.21
images: "ghcr.io/${{ env.GITHUB_IMAGE }}"
tags: |
raw,latest
type=ref,event=branch
type=ref,event=pr
type=ref,event=tag
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}

- uses: actions/cache@v3
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
- name: Set outputs
id: set-outputs
run: |
echo "IMAGE_NAME=${{ env.GITHUB_IMAGE }}" >> $GITHUB_OUTPUT
echo "DOCKER_IMG_NAME=${{env.DOCKER_REPO}}/${{ env.DOCKER_IMAGE }}" >> $GITHUB_OUTPUT

operator-build:
runs-on: ubuntu-latest
timeout-minutes: 30
name: Build Image for Fluent Operator
needs:
- build-image-metadata
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.REGISTRY_USER }}
password: ${{ secrets.REGISTRY_PASSWORD }}
- name: Set up QEMU
uses: docker/setup-qemu-action@v3

- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v3

- name: Build and Push Image for Fluent Operator
run: |
tag=$(cat VERSION | tr -d " \t\n\r")
make build-op -e FO_IMG=${{ env.REGISTRY_REPO }}/fluent-operator:$tag
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build and push
uses: docker/build-push-action@v5
with:
context: .
file: ./cmd/fluent-manager/Dockerfile
push: true
platforms: linux/amd64,linux/arm64
tags: ${{ needs.build-image-metadata.outputs.tags }}
labels: ${{ needs.build-image-metadata.outputs.labels }}

scan-operator-image:
name: Scan Docker Image
needs:
- operator-build
- build-image-metadata
uses: ./.github/workflows/scan-docker-image-action.yaml
with:
source_image: "${{ needs.build-image-metadata.outputs.IMG_NAME }}:${{ needs.build-image-metadata.outputs.version }}"
source_registry: ghcr.io
platforms: "['linux/arm64', 'linux/amd64']"
secrets:
registry_username: ${{ github.actor }}
registry_password: ${{ secrets.GITHUB_TOKEN }}

release-image-to-docker-hub:
if: ${{ github.event_name != 'pull_request' }}
name: Release Image to Docker Hub
uses: ./.github/workflows/clone-docker-image-action.yaml
needs:
- operator-build
- scan-operator-image
- build-image-metadata
with:
source_image: "${{ needs.build-image-metadata.outputs.IMG_NAME }}:${{ needs.build-image-metadata.outputs.version }}"
source_registry: ghcr.io
target_image: "${{ needs.build-image-metadata.outputs.DOCKER_IMG_NAME }}:${{ needs.build-image-metadata.outputs.version }}"
target_registry: docker.io
platforms: "['linux/arm64', 'linux/amd64']"
secrets:
source_registry_username: ${{ github.actor }}
source_registry_token: ${{ secrets.GITHUB_TOKEN }}
target_registry_username: ${{ secrets.REGISTRY_USER }}
target_registry_token: ${{ secrets.REGISTRY_PASSWORD }}
Loading
Loading