From 4a3ad09e6118a50d7f464aa7286d59554931f5f3 Mon Sep 17 00:00:00 2001 From: juicer Date: Thu, 2 Jan 2025 21:07:36 -0800 Subject: [PATCH 1/4] add VERSION file for fluentbit image Signed-off-by: juicer --- cmd/fluent-watcher/fluentbit/Dockerfile | 4 +++- cmd/fluent-watcher/fluentbit/Dockerfile.debug | 4 +++- cmd/fluent-watcher/fluentbit/VERSION | 1 + 3 files changed, 7 insertions(+), 2 deletions(-) create mode 100644 cmd/fluent-watcher/fluentbit/VERSION diff --git a/cmd/fluent-watcher/fluentbit/Dockerfile b/cmd/fluent-watcher/fluentbit/Dockerfile index dd3b4eb64..051d99b3b 100644 --- a/cmd/fluent-watcher/fluentbit/Dockerfile +++ b/cmd/fluent-watcher/fluentbit/Dockerfile @@ -1,3 +1,5 @@ +ARG FLUENT_BIT_BASE_VERSION=3.2.4 + FROM golang:1.23.2-alpine3.19 as buildergo RUN mkdir -p /fluent-bit RUN mkdir -p /code @@ -6,7 +8,7 @@ WORKDIR /code RUN echo $(ls -al /code) RUN CGO_ENABLED=0 go build -ldflags '-w -s' -o /fluent-bit/fluent-bit /code/cmd/fluent-watcher/fluentbit/main.go -FROM fluent/fluent-bit:3.1.8 +FROM fluent/fluent-bit:${FLUENT_BIT_BASE_VERSION} LABEL Description="Fluent Bit docker image" Vendor="Fluent" Version="1.0" COPY conf/fluent-bit.conf conf/fluent-bit.yaml conf/parsers.conf /fluent-bit/etc/ diff --git a/cmd/fluent-watcher/fluentbit/Dockerfile.debug b/cmd/fluent-watcher/fluentbit/Dockerfile.debug index 1cdfcb1fc..839253480 100644 --- a/cmd/fluent-watcher/fluentbit/Dockerfile.debug +++ b/cmd/fluent-watcher/fluentbit/Dockerfile.debug @@ -1,3 +1,5 @@ +ARG FLUENT_BIT_BASE_VERSION=3.2.4 + FROM golang:1.23.2-alpine3.19 as buildergo RUN mkdir -p /fluent-bit RUN mkdir -p /code @@ -6,7 +8,7 @@ WORKDIR /code RUN echo $(ls -al /code) RUN CGO_ENABLED=0 go build -ldflags '-w -s' -o /fluent-bit/fluent-bit /code/cmd/fluent-watcher/fluentbit/main.go -FROM fluent/fluent-bit:3.1.8-debug +FROM fluent/fluent-bit:${FLUENT_BIT_BASE_VERSION}-debug LABEL Description="Fluent Bit docker image" Vendor="Fluent" Version="1.0" COPY conf/fluent-bit.conf conf/fluent-bit.yaml conf/parsers.conf /fluent-bit/etc/ diff --git a/cmd/fluent-watcher/fluentbit/VERSION b/cmd/fluent-watcher/fluentbit/VERSION new file mode 100644 index 000000000..9b7a431d9 --- /dev/null +++ b/cmd/fluent-watcher/fluentbit/VERSION @@ -0,0 +1 @@ +3.2.4 \ No newline at end of file From 3b67bb72b0b74171c77061e78027837691673ffc Mon Sep 17 00:00:00 2001 From: juicer Date: Thu, 2 Jan 2025 21:13:22 -0800 Subject: [PATCH 2/4] add job to get fluent-bit version from file Signed-off-by: juicer --- .github/workflows/build-fb-image.yaml | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/.github/workflows/build-fb-image.yaml b/.github/workflows/build-fb-image.yaml index bb3f40463..640ffa633 100644 --- a/.github/workflows/build-fb-image.yaml +++ b/.github/workflows/build-fb-image.yaml @@ -2,11 +2,6 @@ name: Building Fluent Bit image on: workflow_dispatch: - inputs: - docker_tag_version: - description: 'Fluent Bit image release version' - required: true - default: '3.1.8' env: DOCKER_REPO: 'kubesphere' @@ -18,7 +13,24 @@ permissions: packages: write jobs: + get-version: + runs-on: ubuntu-latest + name: get fluent-bit version + outputs: + VERSION: ${{ steps.get-version.outputs.VERSION }} + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Read fluent-bit version from file + id: get-version + run: | + VERSION=$(cat cmd/fluent-watcher/fluentbit/VERSION) # Read the version from the VERSION file + echo "VERSION=$VERSION" >> $GITHUB_OUTPUT + determine-tags: + needs: + - get-version runs-on: ubuntu-latest name: Determine image tags outputs: @@ -29,7 +41,7 @@ jobs: - name: Determine image version tag id: determine-tags run: | - VERSION=${{ github.event.inputs.docker_tag_version }} + VERSION=${{ steps.get-version.outputs.VERSION }} VERSION_WITHOUT_V=${VERSION#v} MAJOR_MINOR=$(echo $VERSION_WITHOUT_V | cut -d. -f1-2) From 1d2fd5b40f2ba76556fa98cd79b8a496140f21c1 Mon Sep 17 00:00:00 2001 From: juicer Date: Thu, 2 Jan 2025 21:29:30 -0800 Subject: [PATCH 3/4] change it to support run in branch Signed-off-by: juicer --- .github/workflows/build-fb-image.yaml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build-fb-image.yaml b/.github/workflows/build-fb-image.yaml index 640ffa633..45737ffbd 100644 --- a/.github/workflows/build-fb-image.yaml +++ b/.github/workflows/build-fb-image.yaml @@ -21,6 +21,8 @@ jobs: steps: - name: Checkout code uses: actions/checkout@v4 + with: + ref: ${{ github.ref }} - name: Read fluent-bit version from file id: get-version @@ -41,7 +43,7 @@ jobs: - name: Determine image version tag id: determine-tags run: | - VERSION=${{ steps.get-version.outputs.VERSION }} + VERSION=${{ needs.get-version.outputs.VERSION }} VERSION_WITHOUT_V=${VERSION#v} MAJOR_MINOR=$(echo $VERSION_WITHOUT_V | cut -d. -f1-2) From 373dee430c03ff798e594c71e561998eeb6b912c Mon Sep 17 00:00:00 2001 From: juicer Date: Thu, 2 Jan 2025 21:47:39 -0800 Subject: [PATCH 4/4] add build args Signed-off-by: juicer --- .github/workflows/build-fb-image.yaml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/workflows/build-fb-image.yaml b/.github/workflows/build-fb-image.yaml index 45737ffbd..ad6aea939 100644 --- a/.github/workflows/build-fb-image.yaml +++ b/.github/workflows/build-fb-image.yaml @@ -157,6 +157,7 @@ jobs: build-FluentBit-prod-image: needs: + - get-version - build-prod-image-metadata runs-on: ubuntu-latest timeout-minutes: 30 @@ -198,9 +199,12 @@ jobs: platforms: linux/amd64,linux/arm64 tags: ${{ needs.build-prod-image-metadata.outputs.tags }} labels: ${{ needs.build-prod-image-metadata.outputs.labels }} + build-args: | + FLUENT_BIT_BASE_VERSION=${{ needs.get-version.outputs.VERSION }} build-FluentBit-debug-image: needs: + - get-version - build-debug-image-metadata runs-on: ubuntu-latest timeout-minutes: 30 @@ -242,6 +246,8 @@ jobs: platforms: linux/amd64,linux/arm64 tags: ${{ needs.build-debug-image-metadata.outputs.tags }} labels: ${{ needs.build-debug-image-metadata.outputs.labels }} + build-args: | + FLUENT_BIT_BASE_VERSION=${{ needs.get-version.outputs.VERSION }} scan-FluentBit-image: name: Scan prod image