From e76d7b54d64e7aa2f93d84c63855d7c1dfc18dca Mon Sep 17 00:00:00 2001 From: Davide Pesavento Date: Tue, 9 Apr 2024 16:54:01 -0400 Subject: [PATCH] Redesign Dockerfiles using new ndn-cxx base images Refs: #5303 Change-Id: I1a78db309e0443410f5b585f3b0318408e30f76d --- .jenkins.d/00-deps.sh | 5 +- Dockerfile | 72 ++++++++++++++----------- README.md | 5 +- tools/Dockerfile.nfd-status-http-server | 20 +++++-- 4 files changed, 61 insertions(+), 41 deletions(-) diff --git a/.jenkins.d/00-deps.sh b/.jenkins.d/00-deps.sh index df1e4338..ad3828eb 100755 --- a/.jenkins.d/00-deps.sh +++ b/.jenkins.d/00-deps.sh @@ -2,7 +2,8 @@ set -eo pipefail APT_PKGS=( - build-essential + dpkg-dev + g++ libboost-chrono-dev libboost-date-time-dev libboost-dev @@ -17,7 +18,7 @@ APT_PKGS=( libssl-dev libsystemd-dev pkg-config - python3-minimal + python3 ) FORMULAE=(boost openssl pkg-config) PIP_PKGS=() diff --git a/Dockerfile b/Dockerfile index 0a917e46..1b53e3b7 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,45 +1,53 @@ -FROM ghcr.io/named-data/ndn-cxx:latest as builder +# syntax=docker/dockerfile:1 -RUN apt-get update \ - && apt-get install -y --no-install-recommends libpcap-dev \ - && rm -rf /var/lib/apt/lists/* - -COPY . /NFD - -RUN cd /NFD \ - && ./waf configure --without-pch --prefix=/usr --sysconfdir=/etc --localstatedir=/var \ - && ./waf \ - && ./waf install \ - # get list of dependencies - && mkdir -p /shlibdeps/debian && cd /shlibdeps && touch debian/control \ - && dpkg-shlibdeps --ignore-missing-info /usr/lib/libndn-cxx.so* /usr/bin/nfdc /usr/bin/nfd \ - && sed -n '/^shlibs:Depends=/ s|shlibs:Depends=||p' debian/substvars | sed -e 's|,||g' -e 's| ([^)]*)||g' > /deps.txt - -# use same base distro version as named-data/ndn-cxx -FROM debian:bookworm +ARG NDN_CXX_VERSION=latest +FROM ghcr.io/named-data/ndn-cxx-build:${NDN_CXX_VERSION} AS build +ARG SOURCE_DATE_EPOCH -COPY --from=builder /deps.txt / -RUN apt-get update \ - && apt-get install -y --no-install-recommends $(cat /deps.txt) \ - && rm -rf /var/lib/apt/lists/* /deps.txt - -COPY --from=builder /usr/lib/libndn-cxx.so* /usr/lib/ -COPY --from=builder /usr/bin/nfd /usr/bin/ -COPY --from=builder /usr/bin/nfdc /usr/bin/ +RUN apt-get install -Uy --no-install-recommends \ + libpcap-dev \ + # use 'apt-get distclean' when we upgrade to ubuntu:24.04 + && rm -rf /var/lib/apt/lists/* -COPY --from=builder /usr/bin/nfd-status-http-server /usr/bin/ -COPY --from=builder /usr/share/ndn/ /usr/share/ndn/ +RUN --mount=type=bind,rw,target=/src < "${binary}" +done +EOF + +FROM ghcr.io/named-data/ndn-cxx-runtime:${NDN_CXX_VERSION} AS nfd +ARG SOURCE_DATE_EPOCH + +RUN --mount=type=bind,from=build,source=/deps,target=/deps \ + apt-get install -Uy --no-install-recommends $(cat /deps/nfd /deps/nfdc) \ + && rm -rf /var/lib/apt/lists/* -COPY --from=builder /etc/ndn/nfd.conf.sample /config/nfd.conf +COPY --link --from=build /usr/bin/nfd /usr/bin/ +COPY --link --from=build /usr/bin/nfdc /usr/bin/ +COPY --link --from=build /etc/ndn/nfd.conf.sample /config/nfd.conf ENV HOME=/config VOLUME /config VOLUME /run/nfd -EXPOSE 6363/tcp -EXPOSE 6363/udp -EXPOSE 9696/tcp +EXPOSE 6363/tcp 6363/udp 9696/tcp ENTRYPOINT ["/usr/bin/nfd"] CMD ["--config", "/config/nfd.conf"] diff --git a/README.md b/README.md index 28707da0..19430652 100644 --- a/README.md +++ b/README.md @@ -6,10 +6,11 @@ +![Latest version](https://img.shields.io/github/v/tag/named-data/NFD?label=Latest%20version) +![Language](https://img.shields.io/badge/C%2B%2B-17-blue) [![CI](https://github.com/named-data/NFD/actions/workflows/ci.yml/badge.svg)](https://github.com/named-data/NFD/actions/workflows/ci.yml) +[![Docker](https://github.com/named-data/NFD/actions/workflows/docker.yml/badge.svg)](https://github.com/named-data/NFD/actions/workflows/docker.yml) [![Docs](https://github.com/named-data/NFD/actions/workflows/docs.yml/badge.svg)](https://github.com/named-data/NFD/actions/workflows/docs.yml) -![Language](https://img.shields.io/badge/C%2B%2B-17-blue) -![Latest version](https://img.shields.io/github/v/tag/named-data/NFD?label=Latest%20version) ## Overview diff --git a/tools/Dockerfile.nfd-status-http-server b/tools/Dockerfile.nfd-status-http-server index 62545acb..179f9a69 100644 --- a/tools/Dockerfile.nfd-status-http-server +++ b/tools/Dockerfile.nfd-status-http-server @@ -1,12 +1,22 @@ -FROM ghcr.io/named-data/nfd:latest +# syntax=docker/dockerfile:1 -RUN apt-get update \ - && apt-get install -y --no-install-recommends python3 \ +ARG NDN_CXX_VERSION=latest +ARG NFD_VERSION=latest +FROM ghcr.io/named-data/nfd-build:${NFD_VERSION} AS build + +FROM ghcr.io/named-data/ndn-cxx-runtime:${NDN_CXX_VERSION} + +RUN --mount=type=bind,from=build,source=/deps,target=/deps \ + apt-get install -Uy --no-install-recommends $(cat /deps/nfdc) \ + python3 \ && rm -rf /var/lib/apt/lists/* +COPY --link --from=build /usr/bin/nfdc /usr/bin/ +COPY --link --from=build /usr/bin/nfd-status-http-server /usr/bin/ +COPY --link --from=build /usr/share/ndn/ /usr/share/ndn/ + VOLUME /run/nfd EXPOSE 8080/tcp -ENTRYPOINT ["/usr/bin/nfd-status-http-server"] -CMD ["--address", "0.0.0.0", "--port", "8080"] +ENTRYPOINT ["/usr/bin/nfd-status-http-server", "--address", "0.0.0.0"]