Skip to content
Snippets Groups Projects
Dockerfile 2.07 KiB
Newer Older
## Intermediate stage ##
FROM debian:bullseye-slim

# Environment
ENV BUILD_PKGS \
    autoconf \
    automake \
    gcc \
    libedit-dev \
Daniel Salzman's avatar
Daniel Salzman committed
    libelf-dev \
    libfstrm-dev \
    libgnutls28-dev \
    libidn2-0-dev \
    liblmdb-dev \
    libmaxminddb-dev \
    libnghttp2-dev \
    libprotobuf-c-dev \
    libtool \
    liburcu-dev \
    make \
    pkg-config \
    protobuf-c-compiler

# Install dependencies
RUN apt-get update && \
    apt-get install -yqq ${BUILD_PKGS}

# Build the project
WORKDIR /knot-src
ARG FASTPARSER=disable
    CFLAGS="-g -O2 -DNDEBUG -D_FORTIFY_SOURCE=2 -fstack-protector-strong" \
                --with-rundir=/rundir \
                --with-storage=/storage \
                --with-configdir=/config \
                --with-module-dnstap=yes \
                --${FASTPARSER}-fastparser \
                --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:bullseye-slim
MAINTAINER Knot DNS <knot-dns@labs.nic.cz>
# Environment
ENV RUNTIME_PKGS \
    libedit2 \
Daniel Salzman's avatar
Daniel Salzman committed
    libelf1 \
    libfstrm0 \
    libgnutls30 \
    libidn2-0 \
    liblmdb0 \
    libmaxminddb0 \
    libnghttp2-14 \
    libprotobuf-c1 \

# Copy artifacts
COPY --from=0 /tmp/knot-install/ /

# Install dependencies and create knot user and group
ARG UID=53
RUN apt-get update && \
    apt-get install -yqq ${RUNTIME_PKGS} && \
    rm -rf /var/lib/apt/lists/* && \
    ldconfig && \
    adduser --quiet --system --group --no-create-home --home /storage --uid=${UID} knot && \
    chown knot:knot /config /rundir /storage
EXPOSE 53/UDP
EXPOSE 53/TCP
# Prepare shared directories
VOLUME /config
VOLUME /rundir
VOLUME /storage