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

Add build and push image CI #213

Merged
merged 2 commits into from
Feb 23, 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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
46 changes: 46 additions & 0 deletions .github/workflows/build-fb-image.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: Building Fluent Bit image

on:
push:
branches:
- 'master'
tags:
- 'v*'
paths:
- ".github/workflows/build-fb-image.yaml"
- "cmd/fluent-watcher/fluentbit/**"
- "pkg/filenotify/**"

env:
FB_IMG: 'kubesphere/fluent-bit:v1.8.11'

jobs:
build:
runs-on: ubuntu-latest
timeout-minutes: 30
name: Build Image for Fluent Bit and Fluentd
steps:
- name: Install Go
uses: actions/setup-go@v2
with:
go-version: 1.16.x

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

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

- name: Login to Docker Hub
uses: docker/login-action@v1
with:
username: ${{ secrets.REGISTRY_USER }}
password: ${{ secrets.REGISTRY_PASSWORD }}

- name: Build and Push Image for Fluent Bit
run: |
make build-fb-amd64 -e FB_IMG=${{ env.FB_IMG }} && docker push ${{ env.FB_IMG }}
46 changes: 46 additions & 0 deletions .github/workflows/build-fd-image.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: Building Fluentd image

on:
push:
branches:
- 'master'
tags:
- 'v*'
paths:
- ".github/workflows/build-fd-image.yaml"
- "cmd/fluent-watcher/fluentd/**"
- "pkg/filenotify/**"

env:
FD_IMG: 'kubesphere/fluentd:v1.14.4'

jobs:
build:
runs-on: ubuntu-latest
timeout-minutes: 30
name: Build Image for Fluent Bit and Fluentd
steps:
- name: Install Go
uses: actions/setup-go@v2
with:
go-version: 1.16.x

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

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

- name: Login to Docker Hub
uses: docker/login-action@v1
with:
username: ${{ secrets.REGISTRY_USER }}
password: ${{ secrets.REGISTRY_PASSWORD }}

- name: Build and Push Image for Fluentd
run: |
make build-fd-amd64 -e FD_IMG=${{ env.FD_IMG }} && docker push ${{ env.FD_IMG }}
57 changes: 57 additions & 0 deletions .github/workflows/build-op-image.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
name: Building Fluent Operator image

on:
push:
branches:
- 'master'
tags:
- 'v*'
paths:
zhu733756 marked this conversation as resolved.
Show resolved Hide resolved
- ".github/workflows/build-op-image.yaml"
- "apis/**"
- "charts/**"
- "cmd/fluent-manager/**"
- "controllers/**"
- "hack/**"
- "manifests/setup/setup.yaml"
- "!pkg/filenotify/**"
- "Makefile"

env:
REGISTRY_REPO: 'kubesphere'

jobs:
operator-build:
runs-on: ubuntu-latest
timeout-minutes: 30
name: Build Image for Fluent Operator
steps:
- name: Install Go
uses: actions/setup-go@v2
with:
go-version: 1.16.x

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

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

- name: Login to Docker Hub
uses: docker/login-action@v1
with:
username: ${{ secrets.REGISTRY_USER }}
password: ${{ secrets.REGISTRY_PASSWORD }}

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

- 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
9 changes: 4 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
VERSION?=$(shell cat VERSION | tr -d " \t\n\r")
# Image URL to use all building/pushing image targets
FB_IMG ?= kubesphere/fluent-bit:v1.8.3
FB_IMG ?= kubesphere/fluent-bit:v1.8.11
FD_IMG ?= kubesphere/fluentd:v1.14.4
FO_IMG ?= kubesphere/fluent-operator:$(VERSION)

AMD64 ?= -amd64
# Produce CRDs that work back to Kubernetes 1.11 (no version conversion)
CRD_OPTIONS ?= "crd:trivialVersions=true,preserveUnknownFields=false"

Expand Down Expand Up @@ -102,15 +101,15 @@ build-amd64: build-op-amd64 build-fb-amd64 build-fd-amd64

# Build amd64 Fluent Operator container image
build-op-amd64:
docker build -f cmd/fluent-manager/Dockerfile . -t ${FO_IMG}${AMD64}
docker build -f cmd/fluent-manager/Dockerfile . -t ${FO_IMG}

# Build amd64 Fluent Bit container image
build-fb-amd64:
docker build -f cmd/fluent-watcher/fluentbit/Dockerfile . -t ${FB_IMG}${AMD64}
docker build -f cmd/fluent-watcher/fluentbit/Dockerfile . -t ${FB_IMG}

# Build amd64 Fluent Bit container image
build-fd-amd64:
docker build -f cmd/fluent-watcher/fluentd/Dockerfile.complete . -t ${FD_IMG}${AMD64}
docker build -f cmd/fluent-watcher/fluentd/Dockerfile.complete . -t ${FD_IMG}

# Push the amd64 docker image
push-amd64:
Expand Down
2 changes: 1 addition & 1 deletion cmd/fluent-watcher/fluentbit/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ WORKDIR /code
RUN echo $(ls -al /code)
RUN CGO_ENABLED=0 go build -i -ldflags '-w -s' -o /fluent-bit/fluent-bit /code/cmd/fluent-watcher/fluentbit/main.go

FROM fluent/fluent-bit:1.8.3
FROM fluent/fluent-bit:1.8.11
LABEL Description="Fluent Bit docker image" Vendor="Fluent" Version="1.0"

COPY conf/fluent-bit.conf conf/parsers.conf /fluent-bit/etc/
Expand Down