Skip to content

Instantly share code, notes, and snippets.

@zllovesuki
Created July 25, 2022 02:35
Show Gist options
  • Save zllovesuki/478a091f9fd338b20042ca9f25049dc7 to your computer and use it in GitHub Desktop.
Save zllovesuki/478a091f9fd338b20042ca9f25049dc7 to your computer and use it in GitHub Desktop.
# source: https://github.com/tcely/dockerhub-powerdns/blob/e96732791a22595def6b2988c1368b0aee66de5d/authoritative/Dockerfile
# changes:
# 1. removed unused backends
# 2. use make -j$(nproc) to speed up deployment builds
# 3. compile with libmaxminddb-dev
FROM alpine AS builder
ARG AUTH_VERSION
RUN apk --update upgrade && \
apk add ca-certificates curl jq && \
apk add --virtual .build-depends \
file gnupg g++ make \
boost-dev openssl-dev libsodium-dev lua-dev net-snmp-dev protobuf-dev \
libmaxminddb-dev curl-dev mariadb-dev geoip-dev yaml-cpp-dev && \
[ -n "$AUTH_VERSION" ] || { curl -sSL 'https://api.github.com/repos/PowerDNS/pdns/tags?per_page=100&page={1,2,3}' | jq -rs '[.[][]]|map(select(has("name")))|map(select(.name|contains("auth-")))|map(.version=(.name|ltrimstr("auth-")))|map(select(true != (.version|contains("-"))))|map(.version)|"AUTH_VERSION="+.[0]' > /tmp/latest-auth-tag.sh && . /tmp/latest-auth-tag.sh; } && \
mkdir -v -m 0700 -p /root/.gnupg && \
curl -RL -O 'https://www.powerdns.com/powerdns-keyblock.asc' && \
gpg2 --no-options --verbose --keyid-format 0xlong --keyserver-options auto-key-retrieve=true \
--import *.asc && \
curl -RL -O "https://downloads.powerdns.com/releases/pdns-${AUTH_VERSION}.tar.bz2{.asc,.sig,}" && \
gpg2 --no-options --verbose --keyid-format 0xlong --keyserver-options auto-key-retrieve=true \
--verify *.sig && \
rm -rf /root/.gnupg *.asc *.sig && \
tar -xpf "pdns-${AUTH_VERSION}.tar.bz2" && \
rm -f "pdns-${AUTH_VERSION}.tar.bz2" && \
( \
cd "pdns-${AUTH_VERSION}" && \
./configure --sysconfdir=/etc/pdns --mandir=/usr/share/man \
--with-libsodium --enable-tools --enable-lua-records \
--with-modules='bind' \
--with-dynmodules='geoip gmysql' && \
make -j$(nproc) && \
make install-strip \
) && \
apk del --purge .build-depends && rm -rf /var/cache/apk/*
FROM alpine
LABEL maintainer="https://keybase.io/tcely"
RUN apk --update upgrade && \
apk add ca-certificates curl less mdocml \
boost-program_options \
openssl libsodium lua net-snmp protobuf \
mariadb-connector-c \
libmaxminddb geoip yaml-cpp && \
rm -rf /var/cache/apk/*
ENV PAGER less
RUN addgroup -S pdns && \
adduser -S -D -G pdns pdns
COPY --from=builder /usr/local/bin /usr/local/bin/
COPY --from=builder /usr/local/sbin /usr/local/sbin/
COPY --from=builder /usr/local/lib/pdns /usr/local/lib/pdns
COPY --from=builder /usr/share/man/man1 /usr/share/man/man1/
COPY --from=builder /usr/local/share/doc/pdns /usr/local/share/doc/pdns
COPY --from=builder /etc/pdns /etc/pdns/
RUN install -v -d -m 00770 -o root -g pdns /var/run/pdns && ls -l /var/run/
RUN cp -p /etc/pdns/pdns.conf-dist /etc/pdns/pdns.conf && \
/usr/local/sbin/pdns_server --version || [ $? -eq 99 ]
EXPOSE 53/tcp 53/udp
ENTRYPOINT ["/usr/local/sbin/pdns_server"]
CMD ["--help"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment