]> git.ipfire.org Git - thirdparty/lldpd.git/commitdiff
ci: build and publish a Dockerfile
authorVincent Bernat <vincent@bernat.ch>
Mon, 21 Jun 2021 22:20:27 +0000 (00:20 +0200)
committerVincent Bernat <vincent@bernat.ch>
Mon, 21 Jun 2021 22:20:27 +0000 (00:20 +0200)
.dockerignore [new file with mode: 0644]
.github/workflows/ci.yml [moved from .github/workflows/tests.yml with 62% similarity]
Dockerfile [new file with mode: 0644]
NEWS
README.md

diff --git a/.dockerignore b/.dockerignore
new file mode 100644 (file)
index 0000000..5694e6b
--- /dev/null
@@ -0,0 +1,2 @@
+tests/integration/__pycache__
+Dockerfile
similarity index 62%
rename from .github/workflows/tests.yml
rename to .github/workflows/ci.yml
index 4b0cf1c60d921bebe332a6666330f3f6901bef03..2f61f324c939179aad7394285a88929d59330b2d 100644 (file)
@@ -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 (file)
index 0000000..8088a72
--- /dev/null
@@ -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 c53f95a497be16617295081435430f45ac5cc1eb..423ae62a4d184650c3fc7380c70b31d961670bee 100644 (file)
--- 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:
index a356b36c8cd56f892a460ff7bd991c89812f8408..30173691866a80fe05171598d43ba0323f481964 100644 (file)
--- 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