diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml new file mode 100644 index 0000000..ecb08c7 --- /dev/null +++ b/.github/workflows/docker-publish.yml @@ -0,0 +1,66 @@ +name: Docker + +# This workflow uses actions that are not certified by GitHub. +# They are provided by a third-party and are governed by +# separate terms of service, privacy policy, and support +# documentation. + +on: + schedule: + - cron: '0 0 * * *' + push: + branches: [ "master" ] + # Publish semver tags as releases. + tags: [ '*.*.*' ] + pull_request: + branches: [ "master" ] + +env: + # Use docker.io for Docker Hub if empty + REGISTRY: ghcr.io + # github.repository as / + IMAGE_NAME: ${{ github.repository }} + + +jobs: + build: + + runs-on: ubuntu-latest + permissions: + contents: read + packages: write + # This is used to complete the identity challenge + # with sigstore/fulcio when running outside of PRs. + id-token: write + + steps: + - name: Checkout repository + uses: actions/checkout@v3 + + - name: Setup Docker buildx + uses: docker/setup-buildx-action@165fe681b849eec43aaa64d786b9ec53e690475f + + - name: Log into registry ${{ env.REGISTRY }} + if: github.event_name != 'pull_request' + uses: docker/login-action@3da7dc6e2b31f99ef2cb9fb4c50fb0971e0d0139 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Extract Docker metadata + id: meta + uses: docker/metadata-action@507c2f2dc502c992ad446e3d7a5dfbe311567a96 + with: + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + + - name: Build and push Docker image + id: build-and-push + uses: docker/build-push-action@37abcedcc1da61a57767b7588cb9d03eb57e28b3 + with: + context: . + push: ${{ github.event_name != 'pull_request' }} + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + cache-from: type=gha + cache-to: type=gha,mode=max diff --git a/README.md b/README.md index 39cf5f7..eae201a 100644 --- a/README.md +++ b/README.md @@ -17,7 +17,7 @@ version: "3.8" services: docker-engine-events-exporter: - image: neuroforgede/docker-engine-events-exporter:0.1 + image: ghcr.io/neuroforgede/docker-engine-events-exporter:0.1.0 networks: - net environment: @@ -55,7 +55,7 @@ for example about containers with bad exit codes: ```yaml - alert: Container (Swarm) died/is dying with exit code other than 0 - expr: count by (container_attributes_com_docker_swarm_service_name, container_attributes_exitcode, status) ( + expr: count by (docker_hostname, container_attributes_com_docker_swarm_service_name, container_attributes_exitcode, status) ( ( docker_events_container_total{status=~"die|.*oom.*|.*kill.*", container_attributes_exitcode != "0", container_attributes_exitcode != "" } unless diff --git a/build.sh b/build.sh deleted file mode 100644 index d678496..0000000 --- a/build.sh +++ /dev/null @@ -1,8 +0,0 @@ - #!/bin/bash - docker build -f Dockerfile \ - -t neuroforgede/docker-engine-events-exporter:latest \ - -t neuroforgede/docker-engine-events-exporter:0.1 \ - . - -docker push neuroforgede/docker-engine-events-exporter:latest -docker push neuroforgede/docker-engine-events-exporter:0.1 \ No newline at end of file