From 69a635324060293fa12a3845e8f0d0a04cc80a13 Mon Sep 17 00:00:00 2001 From: Siddharth Kulkarni <36110391+siddharthck@users.noreply.github.com> Date: Fri, 13 Oct 2023 01:41:32 +0530 Subject: [PATCH] Add github action workflow for publishing docker image on dockerhub. --- .github/workflows/publish_docker_image.yml | 62 ++++++++++++++++++++++ docker/Dockerfile | 4 ++ 2 files changed, 66 insertions(+) create mode 100644 .github/workflows/publish_docker_image.yml create mode 100644 docker/Dockerfile diff --git a/.github/workflows/publish_docker_image.yml b/.github/workflows/publish_docker_image.yml new file mode 100644 index 0000000..ba6fd0e --- /dev/null +++ b/.github/workflows/publish_docker_image.yml @@ -0,0 +1,62 @@ +on: + workflow_dispatch: + inputs: + dockerImageTag: + description: 'Semver tag with which you want to release the docker image. Ideally it should match with stable plugin version itself. But exceptionally docker image version can be differnt for eg, you update a new depedndency along with plugin inself. ' + required: true + + +env: + # Use docker.io for Docker Hub if empty + REGISTRY: docker.io + # github.repository as / + IMAGE_NAME: logicmonitor/lm-logs-k8s-fluentd + + +jobs: + build: + + runs-on: ubuntu-latest + permissions: + contents: read + packages: write + + steps: + - name: Checkout repository + uses: actions/checkout@v3 + + # Set up BuildKit Docker container builder to be able to build + # multi-platform images and export cache + # https://github.com/docker/setup-buildx-action + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + # Login against a Docker registry except on PR + # https://github.com/docker/login-action + - name: Log into registry ${{ env.REGISTRY }} + if: github.event_name != 'pull_request' + uses: docker/login-action@v3 + with: + registry: ${{ env.REGISTRY }} + username: ${{ vars.DOCKERHUB_USER }} + password: ${{ secrets.DOCKERHUB_PASS }} + + # Extract metadata (tags, labels) for Docker + # https://github.com/docker/metadata-action + - name: Extract Docker metadata + id: meta + uses: docker/metadata-action@v5 + with: + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + tags: type=semver,pattern={{version}},value=v${{ github.event.inputs.dockerImageTag }} + + # Build and push Docker image with Buildx (don't push on PR) + # https://github.com/docker/build-push-action + - name: Build and push Docker image + id: build-and-push + uses: docker/build-push-action@v5 + with: + context: ./docker + push: ${{ github.event_name != 'pull_request' }} + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} diff --git a/docker/Dockerfile b/docker/Dockerfile new file mode 100644 index 0000000..3d58e5c --- /dev/null +++ b/docker/Dockerfile @@ -0,0 +1,4 @@ +FROM fluent/fluentd-kubernetes-daemonset:v1.16-debian-forward-1 +USER root +RUN gem install fluent-plugin-lm-logs -v 1.2.0 +RUN gem install fluent-plugin-multi-format-parser -v 1.0.0