From fe004ae1e6c8fbd17975ba7ff2cd28ce37203fdb Mon Sep 17 00:00:00 2001 From: Thomas Bernard Date: Fri, 8 Sep 2023 15:38:30 +0200 Subject: [PATCH] Add CI job to build rootless filebeat image --- .github/workflows/build-filebeat-rootless.yml | 26 +++++++++++++++++++ infra/filebeat.Dockerfile | 7 +++++ 2 files changed, 33 insertions(+) create mode 100644 .github/workflows/build-filebeat-rootless.yml create mode 100644 infra/filebeat.Dockerfile diff --git a/.github/workflows/build-filebeat-rootless.yml b/.github/workflows/build-filebeat-rootless.yml new file mode 100644 index 000000000..e75db8492 --- /dev/null +++ b/.github/workflows/build-filebeat-rootless.yml @@ -0,0 +1,26 @@ +name: Build and push Filebeat rootless image + +on: + pull_request: + +jobs: + push_to_registry: + name: Push Docker image to Docker Hub + runs-on: ubuntu-latest + steps: + - name: Check out the repo + uses: actions/checkout@v3 + + - name: Login to GHCR + uses: docker/login-action@v2 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Build and push Docker image + uses: docker/build-push-action@3b5e8027fcad23fda98b2e3ac259d8d67585f671 + with: + file: ./infra/filebeat.Dockerfile + push: true + tags: ghcr.io/datalab-mi/basegun/filebeat-rootless:6.5.4 diff --git a/infra/filebeat.Dockerfile b/infra/filebeat.Dockerfile new file mode 100644 index 000000000..544bb7032 --- /dev/null +++ b/infra/filebeat.Dockerfile @@ -0,0 +1,7 @@ +FROM docker.io/elastic/filebeat:6.5.4 +USER root +RUN ls +RUN grep -rlw http /etc |while read i ;do sed -ri 's#\b80\b#8080#' ${i} ; sed -ri 's#\b443\b#6443#' ${i} ;done +RUN find / -xdev -exec chmod -f -c g=u {} \; -exec chown -f -c 1001:root {} \; >/dev/null 2>&1 +RUN grep -w 1001 /etc/passwd ||echo "rootless:x:1001:0:root:/root:/bin/bash" >>/etc/passwd +USER 1001 \ No newline at end of file