knot-dns/Dockerfile

114 lines
3 KiB
Docker
Raw Permalink Normal View History

2018-11-23 03:21:48 -05:00
## Intermediate stage ##
2025-04-28 01:48:20 -04:00
FROM debian:trixie-slim AS builder
2018-11-23 03:21:48 -05:00
# Environment
ENV BUILD_PKGS=" \
2018-11-23 03:21:48 -05:00
autoconf \
automake \
gcc \
libbpf-dev \
2018-11-23 03:21:48 -05:00
libedit-dev \
libfstrm-dev \
libgnutls28-dev \
2025-07-29 11:51:01 -04:00
libhiredis-dev \
libidn2-dev \
2018-11-23 03:21:48 -05:00
liblmdb-dev \
libmaxminddb-dev \
libmnl-dev \
2020-07-20 04:03:47 -04:00
libnghttp2-dev \
2023-01-20 13:18:42 -05:00
libngtcp2-crypto-gnutls-dev \
libngtcp2-dev \
2018-11-23 03:21:48 -05:00
libprotobuf-c-dev \
libsystemd-dev \
2018-11-23 03:21:48 -05:00
libtool \
liburcu-dev \
libxdp-dev \
2018-11-23 03:21:48 -05:00
make \
pkg-config \
protobuf-c-compiler \
protobuf-compiler"
2018-11-23 03:21:48 -05:00
# Install dependencies
RUN apt-get update && \
apt-get install -yqq ${BUILD_PKGS}
# Build the project
COPY . /knot-src
2018-11-23 03:21:48 -05:00
WORKDIR /knot-src
ARG FASTPARSER=disable
RUN autoreconf -if && \
CFLAGS="-g -O2 -DNDEBUG -D_FORTIFY_SOURCE=3 -fstack-protector-strong" \
./configure --prefix=/ \
2018-11-23 03:21:48 -05:00
--with-rundir=/rundir \
--with-storage=/storage \
--with-configdir=/config \
--with-module-dnstap=yes \
--${FASTPARSER}-fastparser \
--enable-quic \
2025-07-29 11:51:01 -04:00
--enable-redis \
--enable-dnstap \
2018-11-23 03:21:48 -05:00
--disable-static \
--disable-documentation && \
make -j$(grep -c ^processor /proc/cpuinfo)
# Run unittests if requested and install the project
ARG CHECK=disable
RUN if [ "$CHECK" = "enable" ]; then make -j$(grep -c ^processor /proc/cpuinfo) check; fi && \
make install DESTDIR=/tmp/knot-install
2018-11-23 03:21:48 -05:00
## Final stage ##
2025-04-28 01:48:20 -04:00
FROM debian:trixie-slim
LABEL maintainer="Knot DNS <knot-dns@labs.nic.cz>"
2015-01-02 06:52:55 -05:00
2018-11-23 03:21:48 -05:00
# Environment
ENV RUNTIME_PKGS=" \
dbus \
libbpf1 \
2018-11-23 03:21:48 -05:00
libedit2 \
libfstrm0 \
libgnutls30t64 \
2025-07-29 11:51:01 -04:00
libhiredis1.1.0 \
libidn2-0 \
2018-11-23 03:21:48 -05:00
liblmdb0 \
libmaxminddb0 \
libmnl0 \
2020-07-20 04:03:47 -04:00
libnghttp2-14 \
2025-04-28 01:48:20 -04:00
libngtcp2-crypto-gnutls8 \
libngtcp2-16 \
2018-11-23 03:21:48 -05:00
libprotobuf-c1 \
liburcu8t64 \
libxdp1"
2018-11-23 03:21:48 -05:00
# Install dependencies and create knot user and group
ARG UID=53
2018-11-23 03:21:48 -05:00
RUN apt-get update && \
2023-01-20 08:59:21 -05:00
apt-get install -yqq ${RUNTIME_PKGS} adduser && \
2018-11-23 03:21:48 -05:00
rm -rf /var/lib/apt/lists/* && \
ldconfig && \
adduser --quiet --system --group --no-create-home --home /storage --uid=${UID} knot && \
2023-01-20 08:59:21 -05:00
install -o knot -g knot -d /config /rundir /storage
# Copy artifacts
2023-01-20 13:01:10 -05:00
# `COPY --from=builder /tmp/knot-install/ /` doesn't work with DOCKER_BUILDKIT=1 under buildx
COPY --from=builder /tmp/knot-install/bin/ /bin/
COPY --from=builder /tmp/knot-install/config/ /config/
COPY --from=builder /tmp/knot-install/include/ /include/
COPY --from=builder /tmp/knot-install/lib/ /lib/
COPY --from=builder /tmp/knot-install/sbin/ /sbin/
2015-01-02 06:52:55 -05:00
# Prepare configurations for optional D-Bus signaling
COPY --from=builder /knot-src/distro/common/system-local.conf /etc/dbus-1/
COPY --from=builder /knot-src/distro/common/cz.nic.knotd.conf /usr/share/dbus-1/system.d/
RUN mkdir -p /run/dbus
2015-01-02 06:52:55 -05:00
# Expose port
EXPOSE 53/udp
EXPOSE 53/tcp
EXPOSE 853/udp
EXPOSE 853/tcp
2015-02-03 13:26:37 -05:00
2018-11-23 03:21:48 -05:00
# Prepare shared directories
VOLUME /config
VOLUME /rundir
VOLUME /storage