From a244ecfbba82925aacc0f0e75b056ea7219e7a0c Mon Sep 17 00:00:00 2001 From: Vincent Bernat Date: Tue, 22 Jun 2021 00:20:27 +0200 Subject: [PATCH] ci: build and publish a Dockerfile --- .dockerignore | 2 ++ .github/workflows/{tests.yml => ci.yml} | 39 +++++++++++++++++++++++++ Dockerfile | 32 ++++++++++++++++++++ NEWS | 2 ++ README.md | 18 ++++++++++++ 5 files changed, 93 insertions(+) create mode 100644 .dockerignore rename .github/workflows/{tests.yml => ci.yml} (62%) create mode 100644 Dockerfile diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 00000000..5694e6b9 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,2 @@ +tests/integration/__pycache__ +Dockerfile diff --git a/.github/workflows/tests.yml b/.github/workflows/ci.yml similarity index 62% rename from .github/workflows/tests.yml rename to .github/workflows/ci.yml index 4b0cf1c6..2f61f324 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/ci.yml @@ -68,3 +68,42 @@ jobs: name: package path: lldpd-*.pkg if-no-files-found: error + docker: + needs: build + runs-on: ubuntu-latest + name: Build Docker images + if: github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/') + steps: + - uses: actions/checkout@v2 + - uses: docker/setup-qemu-action@v1 + - uses: docker/setup-buildx-action@v1 + - uses: docker/metadata-action@v3 + id: meta + with: + images: | + ghcr.io/lldpd/lldpd + tags: | + type=schedule,pattern=master + type=ref,event=branch + type=semver,pattern={{version}} + type=semver,pattern={{major}}.{{minor}} + type=semver,pattern={{major}} + - uses: docker/login-action@v1 + with: + registry: ghcr.io + username: ${{ github.repository_owner }} + password: ${{ secrets.GITHUB_TOKEN }} + - uses: docker/build-push-action@v2 + with: + context: . + file: Dockerfile + platforms: | + linux/amd64 + linux/arm64 + linux/ppc64el + linux/i386 + linux/arm/v7 + linux/arm/v6 + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 00000000..8088a726 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,32 @@ +FROM alpine:latest AS build +RUN apk add autoconf automake libtool \ + libevent-dev libxml2-dev jansson-dev \ + readline-dev libcap-dev alpine-sdk +WORKDIR /build +COPY . . +RUN ./autogen.sh +RUN ./configure \ + --prefix=/usr \ + --sysconfdir=/etc \ + --enable-pie \ + --enable-hardening \ + --without-embedded-libevent \ + --without-snmp \ + --with-xml \ + --with-privsep-user=_lldpd \ + --with-privsep-group=_lldpd \ + --with-privsep-chroot=/run/lldpd \ + --with-lldpd-ctl-socket=/run/lldpd.socket \ + --with-lldpd-pid-file=/run/lldpd.pid +RUN make +RUN make install DESTDIR=/lldpd + +FROM alpine:latest +RUN apk add libevent libxml2 jansson readline libcap \ + && addgroup -S _lldpd \ + && adduser -S -G _lldpd -D -H -g "lldpd user" _lldpd +COPY --from=build /lldpd / +VOLUME /etc/lldpd.d +ENTRYPOINT ["lldpd", "-d"] +CMD [] + diff --git a/NEWS b/NEWS index c53f95a4..423ae62a 100644 --- a/NEWS +++ b/NEWS @@ -2,6 +2,8 @@ lldpd (1.0.12) * Fix: + Use a dedicated file lock to prevent concurrent changes from lldpcli. + Require/display powerpairs for Dot3 power even when device type is PD. + * Changes: + + Provide a Docker image and make it availble on GitHub. lldpd (1.0.11) * Changes: diff --git a/README.md b/README.md index a356b36c..30173691 100644 --- a/README.md +++ b/README.md @@ -59,6 +59,24 @@ syslog, copy `/etc/locatime` into the chroot. line. If you don't want to run it as root, just install it setuid or setgid `_lldpd`. +## Installation (Docker) + +You can use Docker to run `lldpd`: + + docker run --rm --net=host --uts=host \ + -v /etc/os-release:/etc/os-release \ + --cap-add=NET_RAW --cap-add=NET_ADMIN \ + --name lldpd \ + ghcr.io/lldpd/lldpd:latest + +To execute `lldpcli`, use: + + docker exec lldpd lldpcli show neighbors + +Or to get the command-line: + + docker exec -it lldpd lldpcli + ## Installation (macOS) The same procedure as above applies for macOS. However, there are -- 2.39.5