]> git.ipfire.org Git - thirdparty/pdns.git/blob - Dockerfile-recursor
Merge pull request #14078 from rgacogne/ddist-harvest-quic
[thirdparty/pdns.git] / Dockerfile-recursor
1 # USAGE
2
3 # docker build --build-arg MAKEFLAGS=-j8 -t recursor -f docker/Dockerfile-recursor .
4 # docker run -p 1053:53 -p 1053:53/udp -ti --rm recursor
5 # dig a www.example.com @0 -p 1053
6
7 # Builder
8 FROM debian:11-slim AS builder
9
10 ENV NO_LUA_JIT="s390x arm64"
11
12 # Reusable layer for base update
13 RUN apt-get update && apt-get -y dist-upgrade && apt-get clean
14
15 # devscripts gives us mk-build-deps (and a lot of other stuff)
16 RUN apt-get install -y --no-install-recommends devscripts equivs git curl jq && apt-get clean
17
18 COPY builder-support /source/builder-support
19
20 # TODO: control file is not in tarballs at all right now
21 RUN mk-build-deps -i -t 'apt-get -y -o Debug::pkgProblemResolver=yes --no-install-recommends' /source/builder-support/debian/recursor/debian-buster/control && \
22 apt-get clean
23
24 COPY pdns /source/pdns
25 COPY build-aux /source/build-aux
26 COPY m4 /source/m4
27 COPY ext /source/ext
28 COPY .git /source/.git
29 COPY builder/helpers/set-configure-ac-version.sh /usr/local/bin
30
31 COPY builder-support/helpers/install_rust.sh /source/install_rust.sh
32 COPY builder-support/helpers/rust.json /source/rust.json
33 RUN cd /source/ && ./install_rust.sh
34
35 # build and install (TODO: before we hit this line, rearrange /source structure if we are coming from a tarball)
36 WORKDIR /source/pdns/recursordist
37
38 ARG MAKEFLAGS=
39 ENV MAKEFLAGS ${MAKEFLAGS:--j2}
40
41 ARG DOCKER_FAKE_RELEASE=NO
42 ENV DOCKER_FAKE_RELEASE ${DOCKER_FAKE_RELEASE}
43
44 # Manpage deps
45 # RUN apt-get install -y python3-venv && apt-get clean
46
47 # Manpage prevent
48 RUN touch pdns_recursor.1 rec_control.1 # avoid installing pandoc
49
50 RUN if [ "${DOCKER_FAKE_RELEASE}" = "YES" ]; then \
51 BUILDER_VERSION="$(IS_RELEASE=YES BUILDER_MODULES=recursor ./builder-support/gen-version | sed 's/\([0-9]\+\.[0-9]\+\.[0-9]\+\(\(alpha|beta|rc\)\d\+\)\)?.*/\1/')" set-configure-ac-version.sh;\
52 fi && \
53 BUILDER_MODULES=recursor autoreconf -vfi
54
55 RUN mkdir /build && \
56 LUAVER=$([ -z "${NO_LUA_JIT##*$(dpkg --print-architecture)*}" ] && echo 'lua5.3' || echo 'luajit') && \
57 ./configure \
58 --with-lua=${LUAVER} \
59 LDFLAGS=-rdynamic \
60 --sysconfdir=/etc/powerdns \
61 --enable-option-checking=fatal && \
62 make clean && \
63 make $MAKEFLAGS install DESTDIR=/build && make clean && \
64 strip /build/usr/local/bin/* /build/usr/local/sbin/*
65 RUN cd /tmp && mkdir /build/tmp/ && mkdir debian && \
66 echo 'Source: docker-deps-for-pdns' > debian/control && \
67 dpkg-shlibdeps /build/usr/local/bin/rec_control /build/usr/local/sbin/pdns_recursor && \
68 sed 's/^shlibs:Depends=/Depends: /' debian/substvars >> debian/control && \
69 equivs-build debian/control && \
70 dpkg-deb -I equivs-dummy_1.0_all.deb && cp equivs-dummy_1.0_all.deb /build/tmp/
71
72 # Runtime
73 FROM debian:11-slim
74
75 # Reusable layer for base update - Should be cached from builder
76 RUN apt-get update && apt-get -y dist-upgrade && apt-get clean
77
78 # Ensure python3 and jinja2 is present (for startup script), and tini for signal management
79 RUN apt-get install -y python3 python3-jinja2 tini libcap2-bin && apt-get clean
80
81 # Executables from builder
82 COPY --from=builder /build /
83 RUN chmod 1777 /tmp # FIXME: better not use /build/tmp for equivs at all
84
85 # Ensure dependencies are present
86 RUN apt-get install -y /tmp/equivs-dummy_1.0_all.deb && apt-get clean
87
88 # Start script
89 COPY dockerdata/startup.py /usr/local/sbin/pdns_recursor-startup
90
91 # Config file(s) from builder
92 COPY dockerdata/recursor.conf /etc/powerdns/
93
94 # Is recursor.d necessary if we copy the config into recursor.conf? (see above)
95 RUN mkdir -p /etc/powerdns/recursor.d /var/run/pdns-recursor /etc/powerdns/templates.d
96
97 # Work with pdns user - not root
98 RUN adduser --system --disabled-password --disabled-login --no-create-home --group pdns --uid 953
99 RUN chown pdns:pdns /var/run/pdns-recursor /etc/powerdns/recursor.d /etc/powerdns/templates.d
100 USER pdns
101
102 # Default DNS ports
103 EXPOSE 53/udp
104 EXPOSE 53/tcp
105
106 # Default webserver port
107 EXPOSE 8082/tcp
108
109 ENTRYPOINT ["/usr/bin/tini", "--", "/usr/local/sbin/pdns_recursor-startup"]