Skip to content

Commit

Permalink
Redesign Dockerfiles using new ndn-cxx base images
Browse files Browse the repository at this point in the history
Refs: #5303
Change-Id: I1a78db309e0443410f5b585f3b0318408e30f76d
  • Loading branch information
Pesa committed Apr 9, 2024
1 parent 183e188 commit e76d7b5
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 41 deletions.
5 changes: 3 additions & 2 deletions .jenkins.d/00-deps.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
set -eo pipefail

APT_PKGS=(
build-essential
dpkg-dev
g++
libboost-chrono-dev
libboost-date-time-dev
libboost-dev
Expand All @@ -17,7 +18,7 @@ APT_PKGS=(
libssl-dev
libsystemd-dev
pkg-config
python3-minimal
python3
)
FORMULAE=(boost openssl pkg-config)
PIP_PKGS=()
Expand Down
72 changes: 40 additions & 32 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -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 <<EOF
set -eux
cd /src
./waf configure \
--prefix=/usr \
--libdir=/usr/lib \
--sysconfdir=/etc \
--localstatedir=/var \
--sharedstatedir=/var \
--without-systemd
./waf build
./waf install

mkdir -p /deps/debian
touch /deps/debian/control
cd /deps
for binary in nfd nfdc nfd-autoreg; do
dpkg-shlibdeps --ignore-missing-info "/usr/bin/${binary}" -O \
| sed -n 's|^shlibs:Depends=||p' | sed 's| ([^)]*),\?||g' > "${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"]
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@

</div>

![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

Expand Down
20 changes: 15 additions & 5 deletions tools/Dockerfile.nfd-status-http-server
Original file line number Diff line number Diff line change
@@ -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"]

0 comments on commit e76d7b5

Please sign in to comment.