]> git.ipfire.org Git - thirdparty/pdns.git/blame - Dockerfile-dnsdist
Merge pull request #15757 from Habbie/a-view-to-a-catz
[thirdparty/pdns.git] / Dockerfile-dnsdist
CommitLineData
c0e0545b 1# our chosen base image
cf66dd22 2FROM debian:12-slim AS builder
c0e0545b 3
1e9b17d7 4ENV NO_LUA_JIT="s390x arm64"
c1a8e298 5
c0e0545b
PD
6# TODO: make sure /source looks roughly the same from git or tar
7
8# Reusable layer for base update
9RUN apt-get update && apt-get -y dist-upgrade && apt-get clean
10
732d0aac
RG
11# Unable backports to get a recent enough version of meson
12RUN echo "deb http://deb.debian.org/debian bookworm-backports main" > /etc/apt/sources.list.d/bookworm-backports.list
c0e0545b 13# devscripts gives us mk-build-deps (and a lot of other stuff)
07c957db 14RUN apt-get update && apt-get -y dist-upgrade && apt-get install -y --no-install-recommends devscripts equivs git && apt-get clean
c0e0545b 15
d2a1e0c6 16COPY builder-support /source/builder-support
c0e0545b
PD
17
18# TODO: control file is not in tarballs at all right now
cf66dd22 19RUN mk-build-deps -i -t 'apt-get -y -o Debug::pkgProblemResolver=yes --no-install-recommends' /source/builder-support/debian/dnsdist/debian-bookworm/control && \
732d0aac 20 apt-get install -y -t bookworm-backports meson && \
c0e0545b
PD
21 apt-get clean
22
732d0aac 23COPY meson /source/meson
d2a1e0c6
PL
24COPY pdns /source/pdns
25COPY build-aux /source/build-aux
26COPY m4 /source/m4
27COPY ext /source/ext
ff6b244a 28COPY builder/helpers/set-configure-ac-version.sh /usr/local/bin
d2a1e0c6
PL
29COPY .git /source/.git
30
c0e0545b
PD
31# build and install (TODO: before we hit this line, rearrange /source structure if we are coming from a tarball)
32WORKDIR /source/pdns/dnsdistdist
33
34ARG MAKEFLAGS=
3b47c442 35ENV MAKEFLAGS=${MAKEFLAGS:--j2}
c0e0545b 36
ff6b244a 37ARG DOCKER_FAKE_RELEASE=NO
3b47c442 38ENV DOCKER_FAKE_RELEASE=${DOCKER_FAKE_RELEASE}
ff6b244a 39
c0e0545b
PD
40RUN touch dnsdist.1 # avoid having to install pandoc and venv
41
ff6b244a 42RUN if [ "${DOCKER_FAKE_RELEASE}" = "YES" ]; then \
a508963d 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;\
ff6b244a
PL
44 fi && \
45 BUILDER_MODULES=dnsdist autoreconf -vfi
c0e0545b 46
9a5fe194 47RUN mkdir /quiche && cd /quiche && \
7847df6d 48 apt-get install -y cmake curl jq libclang-dev && \
9a5fe194 49 apt-get clean && \
4ccb0f78
RG
50 cd /source/builder-support/helpers/ && \
51 ./install_rust.sh && \
52 ./install_quiche.sh
9a5fe194 53
c0e0545b 54RUN mkdir /build && \
1e9b17d7 55 LUAVER=$([ -z "${NO_LUA_JIT##*$(dpkg --print-architecture)*}" ] && echo 'lua5.3' || echo 'luajit') && \
732d0aac
RG
56 apt-get install -y lib${LUAVER}-*dev ninja-build && \
57 BUILDDIR=$(mktemp -d) && \
9270aa75 58 IS_RELEASE="${DOCKER_FAKE_RELEASE}" \
732d0aac
RG
59 LDFLAGS="-latomic -fuse-ld=lld -Wl,--build-id=sha1 -ldl" \
60 CC=clang \
61 CXX=clang++ \
62 PKG_CONFIG_PATH=/opt/lib/pkgconfig meson setup ${BUILDDIR} \
c0e0545b 63 --sysconfdir=/etc/dnsdist \
1e4d7996 64 -Dlua=auto \
732d0aac
RG
65 -Db_lto=true \
66 -Db_lto_mode=thin \
67 -Db_pie=true \
45250f07
RG
68 -Ddns-over-https=enabled \
69 -Ddns-over-quic=enabled \
70 -Ddns-over-http3=enabled \
71 -Ddns-over-tls=enabled \
732d0aac
RG
72 -Ddnscrypt=enabled \
73 -Ddnstap=enabled \
74 -Dyaml=enabled \
75 -Debpf=enabled \
76 -Dyaml=enabled \
77 -Dtls-gnutls=enabled \
cc08ca93 78 -Dsnmp=enabled \
732d0aac
RG
79 -Dlibcap=enabled \
80 -Dlibsodium=enabled \
81 -Dquiche=enabled \
82 -Dre2=enabled \
30cd24f3 83 -Dsystemd-service=disabled \
732d0aac
RG
84 -Dxsk=enabled && \
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
368027b7
RG
89
90RUN 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}/"; \
94 break; \
95 fi; \
96 done
9a5fe194 97
c0e0545b 98RUN cd /tmp && mkdir /build/tmp/ && mkdir debian && \
7b968335 99 echo 'Source: docker-deps-for-pdns' > debian/control && \
c0e0545b
PD
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/
104
105# Runtime
106
cf66dd22 107FROM debian:12-slim
c0e0545b
PD
108
109# Reusable layer for base update - Should be cached from builder
110RUN apt-get update && apt-get -y dist-upgrade && apt-get clean
111
d256ad02 112# - python3 and jinja2 (for startup script)
d256ad02
PD
113# - tini (for signal management)
114# - ca-certificates (for verifying downstream DoH/DoT certificates)
f377ae1f 115RUN apt-get install -y python3 python3-jinja2 tini libcap2-bin ca-certificates && apt-get clean
c0e0545b
PD
116
117# Output from builder
118COPY --from=builder /build /
119RUN chmod 1777 /tmp # FIXME: better not use /build/tmp for equivs at all
c0e0545b
PD
120
121# Ensure dependencies are present
2e209af7 122RUN apt-get install -y /tmp/equivs-dummy_1.0_all.deb && apt-get clean
c0e0545b
PD
123
124# Config
6c1e69e0 125RUN mkdir -p /etc/dnsdist/conf.d /etc/dnsdist/templates.d
d2a1e0c6 126COPY dockerdata/dnsdist.conf /etc/dnsdist/
c0e0545b
PD
127
128# Start script
129COPY dockerdata/startup.py /usr/local/bin/dnsdist-startup
130
131# Work with pdns user - not root
132RUN adduser --system --disabled-password --disabled-login --no-create-home --group pdns --uid 953
6c1e69e0 133RUN chown pdns:pdns /etc/dnsdist/conf.d /etc/dnsdist/templates.d
c0e0545b
PD
134USER pdns
135
f28c81ed 136# Default DNS ports
c0e0545b
PD
137EXPOSE 53/udp
138EXPOSE 53/tcp
f28c81ed 139# Default console port
c0e0545b 140EXPOSE 5199/tcp
f28c81ed 141# Default webserver port
c0e0545b
PD
142EXPOSE 8083/tcp
143
144WORKDIR /etc/dnsdist
145
d2a1e0c6 146COPY dockerdata/dnsdist-resolver.lua /etc/dnsdist/
c0e0545b
PD
147
148ENTRYPOINT ["/usr/bin/tini", "--", "/usr/local/bin/dnsdist-startup"]