1 # our chosen base image
2 FROM debian:12-slim AS builder
4 ENV NO_LUA_JIT="s390x arm64"
6 # TODO: make sure /source looks roughly the same from git or tar
8 # Reusable layer for base update
9 RUN apt-get update && apt-get -y dist-upgrade && apt-get clean
11 # Unable backports to get a recent enough version of meson
12 RUN echo "deb http://deb.debian.org/debian bookworm-backports main" > /etc/apt/sources.list.d/bookworm-backports.list
13 # devscripts gives us mk-build-deps (and a lot of other stuff)
14 RUN apt-get update && apt-get -y dist-upgrade && apt-get install -y --no-install-recommends devscripts equivs git && apt-get clean
16 COPY builder-support /source/builder-support
18 # TODO: control file is not in tarballs at all right now
19 RUN mk-build-deps -i -t 'apt-get -y -o Debug::pkgProblemResolver=yes --no-install-recommends' /source/builder-support/debian/dnsdist/debian-bookworm/control && \
20 apt-get install -y -t bookworm-backports meson && \
23 COPY meson /source/meson
24 COPY pdns /source/pdns
25 COPY build-aux /source/build-aux
28 COPY builder/helpers/set-configure-ac-version.sh /usr/local/bin
29 COPY .git /source/.git
31 # build and install (TODO: before we hit this line, rearrange /source structure if we are coming from a tarball)
32 WORKDIR /source/pdns/dnsdistdist
35 ENV MAKEFLAGS=${MAKEFLAGS:--j2}
37 ARG DOCKER_FAKE_RELEASE=NO
38 ENV DOCKER_FAKE_RELEASE=${DOCKER_FAKE_RELEASE}
40 RUN touch dnsdist.1 # avoid having to install pandoc and venv
42 RUN if [ "${DOCKER_FAKE_RELEASE}" = "YES" ]; then \
43 BUILDER_VERSION="$(IS_RELEASE=YES BUILDER_MODULES=dnsdist ./builder-support/gen-version | sed 's/\([0-9]\+\.[0-9]\+\.[0-9]\+\(\(alpha|beta|rc\)\d\+\)\)?.*/\1/')" set-configure-ac-version.sh;\
45 BUILDER_MODULES=dnsdist autoreconf -vfi
47 RUN mkdir /quiche && cd /quiche && \
48 apt-get install -y cmake curl jq libclang-dev && \
50 cd /source/builder-support/helpers/ && \
51 ./install_rust.sh && \
55 LUAVER=$([ -z "${NO_LUA_JIT##*$(dpkg --print-architecture)*}" ] && echo 'lua5.3' || echo 'luajit') && \
56 apt-get install -y lib${LUAVER}-*dev ninja-build && \
57 BUILDDIR=$(mktemp -d) && \
58 IS_RELEASE="${DOCKER_FAKE_RELEASE}" \
59 LDFLAGS="-latomic -fuse-ld=lld -Wl,--build-id=sha1 -ldl" \
62 PKG_CONFIG_PATH=/opt/lib/pkgconfig meson setup ${BUILDDIR} \
63 --sysconfdir=/etc/dnsdist \
68 -Ddns-over-https=enabled \
69 -Ddns-over-quic=enabled \
70 -Ddns-over-http3=enabled \
71 -Ddns-over-tls=enabled \
77 -Dtls-gnutls=enabled \
83 -Dsystemd-service=disabled \
85 meson compile -C ${BUILDDIR} && \
86 meson install -C ${BUILDDIR} --destdir /build && \
87 strip /build/usr/local/bin/* && \
88 rm -rf /build/lib # remove systemd unit files, we do not need them and copying /lib to the run-time image breaks it
90 RUN for tentative in "lib/x86_64-linux-gnu" "lib/aarch64-linux-gnu" "lib64" "lib"; do \
91 if [ -f "/usr/${tentative}/libdnsdist-quiche.so" ]; then \
92 mkdir -p "/build/usr/${tentative}/"; \
93 cp "/usr/${tentative}/libdnsdist-quiche.so" "/build/usr/${tentative}/"; \
98 RUN cd /tmp && mkdir /build/tmp/ && mkdir debian && \
99 echo 'Source: docker-deps-for-pdns' > debian/control && \
100 dpkg-shlibdeps /build/usr/local/bin/dnsdist && \
101 sed 's/^shlibs:Depends=/Depends: /' debian/substvars >> debian/control && \
102 equivs-build debian/control && \
103 dpkg-deb -I equivs-dummy_1.0_all.deb && cp equivs-dummy_1.0_all.deb /build/tmp/
109 # Reusable layer for base update - Should be cached from builder
110 RUN apt-get update && apt-get -y dist-upgrade && apt-get clean
112 # - python3 and jinja2 (for startup script)
113 # - tini (for signal management)
114 # - ca-certificates (for verifying downstream DoH/DoT certificates)
115 RUN apt-get install -y python3 python3-jinja2 tini libcap2-bin ca-certificates && apt-get clean
117 # Output from builder
118 COPY --from=builder /build /
119 RUN chmod 1777 /tmp # FIXME: better not use /build/tmp for equivs at all
121 # Ensure dependencies are present
122 RUN apt-get install -y /tmp/equivs-dummy_1.0_all.deb && apt-get clean
125 RUN mkdir -p /etc/dnsdist/conf.d /etc/dnsdist/templates.d
126 COPY dockerdata/dnsdist.conf /etc/dnsdist/
129 COPY dockerdata/startup.py /usr/local/bin/dnsdist-startup
131 # Work with pdns user - not root
132 RUN adduser --system --disabled-password --disabled-login --no-create-home --group pdns --uid 953
133 RUN chown pdns:pdns /etc/dnsdist/conf.d /etc/dnsdist/templates.d
139 # Default console port
141 # Default webserver port
146 COPY dockerdata/dnsdist-resolver.lua /etc/dnsdist/
148 ENTRYPOINT ["/usr/bin/tini", "--", "/usr/local/bin/dnsdist-startup"]