librenms / docker

LibreNMS Docker image
MIT License
691 stars 278 forks source link

Auto Build docker image nightly #360

Closed ryanmerolle closed 1 year ago

ryanmerolle commented 1 year ago

Would you be open to autobuilding using something like below? I am happy to create a PR.

.github/workflows/build.yml

name: build

concurrency:
  group: build-${{ github.ref }}
  cancel-in-progress: true

on:
  push:
    branches:
      - 'master'
    tags:
      - '*'
    paths-ignore:
      - '**.md'
  pull_request:
    branches:
      - 'master'
    paths-ignore:
      - '**.md'
  schedule:
    - cron: '45 5 * * *'

env:
  DOCKERHUB_SLUG: librenms/librenms

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      -
        name: Checkout
        uses: actions/checkout@v3
      -
        name: Docker meta
        id: meta
        uses: docker/metadata-action@v4
        with:
          images: |
            ${{ env.DOCKERHUB_SLUG }}
          tags: |
            type=match,pattern=(.*)-r,group=1
            type=ref,event=pr
            type=edge
          labels: |
            org.opencontainers.image.title=LibreNMS
            org.opencontainers.image.description=Fully featured network monitoring system
            org.opencontainers.image.vendor=LibreNMS
      -
        name: Get latest LibreNMS version
        id: librenms_version
        run: |
          LIBRENMS_VERSION=$(curl --silent "https://api.github.com/repos/librenms/librenms/releases/latest" | grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/')
          echo "::set-output name=version::${LIBRENMS_VERSION}"
      -
        name: Set up QEMU
        uses: docker/setup-qemu-action@v2
      -
        name: Set up Docker Buildx
        uses: docker/setup-buildx-action@v2
      -
        name: Login to DockerHub
        if: github.event_name != 'pull_request'
        uses: docker/login-action@v2
        with:
          username: ${{ secrets.DOCKER_USERNAME }}
          password: ${{ secrets.DOCKER_PASSWORD }}
      -
        name: Build
        uses: docker/bake-action@v3
        with:
          files: |
            ./docker-bake.hcl
            ${{ steps.meta.outputs.bake-file }}
          targets: image-all
          push: ${{ github.event_name != 'pull_request' }}
          args: LIBRENMS_VERSION=${{ steps.librenms_version.outputs.version }}
      -
        name: Check manifest
        if: github.event_name != 'pull_request'
        run: |
          docker buildx imagetools inspect ${{ env.DOCKERHUB_SLUG }}:${{ steps.meta.outputs.version }}
      -
        name: Inspect
        if: github.event_name != 'pull_request'
        run: |
          docker pull ${{ env.DOCKERHUB_SLUG }}:${{ steps.meta.outputs.version }}
          docker image inspect ${{ env.DOCKERHUB_SLUG }}:${{ steps.meta.outputs.version }}
jaydio commented 1 year ago

Yes, please!

crazy-max commented 1 year ago

Same as https://github.com/librenms/docker/discussions/377#discussioncomment-6515401. See for example the issue we currently have with arm/v6 arch: https://github.com/librenms/docker/pull/362. We can't blindly build HEAD and hope it works.

crazy-max commented 1 year ago

Also we are already testing master branch in one of our workflow: https://github.com/librenms/docker/actions/runs/5629776927/job/15255117247

If you want to be on edge you can build the image yourself:

$ docker buildx bake image --push --set "*.tags=user/repo:latest"