-
Notifications
You must be signed in to change notification settings - Fork 58
/
Dockerfile
109 lines (98 loc) · 2.86 KB
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
## Intermediate stage ##
FROM debian:bookworm-slim AS builder
# Environment
ENV BUILD_PKGS \
autoconf \
automake \
gcc \
libbpf-dev \
libedit-dev \
libfstrm-dev \
libgnutls28-dev \
libidn2-dev \
liblmdb-dev \
libmaxminddb-dev \
libmnl-dev \
libnghttp2-dev \
libngtcp2-crypto-gnutls-dev \
libngtcp2-dev \
libprotobuf-c-dev \
libsystemd-dev \
libtool \
liburcu-dev \
libxdp-dev \
make \
pkg-config \
protobuf-c-compiler
# Install dependencies
RUN apt-get update && \
apt-get install -yqq ${BUILD_PKGS}
# Build the project
COPY . /knot-src
WORKDIR /knot-src
ARG FASTPARSER=disable
RUN autoreconf -if && \
CFLAGS="-g -O2 -DNDEBUG -D_FORTIFY_SOURCE=3 -fstack-protector-strong" \
./configure --prefix=/ \
--with-rundir=/rundir \
--with-storage=/storage \
--with-configdir=/config \
--with-module-dnstap=yes \
--${FASTPARSER}-fastparser \
--enable-quic \
--enable-dnstap \
--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
## Final stage ##
FROM debian:bookworm-slim
LABEL maintainer="Knot DNS <[email protected]>"
# Environment
ENV RUNTIME_PKGS \
dbus \
libbpf1 \
libedit2 \
libfstrm0 \
libgnutls30 \
libidn2-0 \
liblmdb0 \
libmaxminddb0 \
libmnl0 \
libnghttp2-14 \
libngtcp2-crypto-gnutls2 \
libngtcp2-9 \
libprotobuf-c1 \
liburcu8 \
libxdp1
# Install dependencies and create knot user and group
ARG UID=53
RUN apt-get update && \
apt-get install -yqq ${RUNTIME_PKGS} adduser && \
rm -rf /var/lib/apt/lists/* && \
ldconfig && \
adduser --quiet --system --group --no-create-home --home /storage --uid=${UID} knot && \
install -o knot -g knot -d /config /rundir /storage
# Copy artifacts
# `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/
# 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
# Expose port
EXPOSE 53/UDP
EXPOSE 53/TCP
EXPOSE 853/UDP
EXPOSE 853/TCP
# Prepare shared directories
VOLUME /config
VOLUME /rundir
VOLUME /storage