Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
77 changes: 77 additions & 0 deletions contrib/container/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
FROM debian:stable-slim AS builder

ENV BUILD_PKGS \
build-essential \
autoconf \
libevent-dev \
libssl-dev \
protobuf-compiler \
protobuf-c-compiler \
libprotobuf-c-dev \
libfstrm-dev \
bison \
flex \
curl \
jq \
git

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

# Fetch source
WORKDIR /nsd-src
COPY . /nsd-src
RUN git submodule update --init

# Build the project
RUN autoreconf --install && \
./configure --with-configdir=/config --localstatedir=/storage --enable-root-server && \
make && \
make DESTDIR=/tmp/nsd-install install

# Save result
RUN tar cvzfC /nsd.tar.gz /tmp/nsd-install usr/local config storage


FROM debian:stable-slim

# Environment
ENV RUNTIME_PKGS \
procps \
openssl \
libssl3 \
libevent-2.1 \
libprotobuf-c1 \
libfstrm-dev

# Copy artifacts
COPY --from=builder /nsd.tar.gz /tmp
RUN tar xvzpf /tmp/nsd.tar.gz
RUN rm -f /tmp/nsd.tar.gz

# Install dependencies and create nsd user and group
ARG UID=53
RUN apt-get update && \
apt-get install -yqq ${RUNTIME_PKGS} && \
rm -rf /var/lib/apt/lists/* && \
ldconfig && \
useradd --system --user-group -M --home /storage --uid ${UID} nsd && \
install -d -o nsd -g nsd /config /storage && \
chown -R nsd:nsd /config /storage

# Add default config
ADD container/nsd.conf /config

# Add entrypoint
ADD container/entrypoint.sh /
ENTRYPOINT ["bash", "/entrypoint.sh"]

# Expose port
EXPOSE 53/udp
EXPOSE 53/tcp
EXPOSE 853/tcp

# Prepare shared directories
VOLUME /config
VOLUME /storage
11 changes: 11 additions & 0 deletions contrib/container/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# NSD Container

## Build

Build container using:

docker build -f contrib/container/Dockerfile -t nsd .

## Runtime

Configuration stored in `/config` and volatile data in `/storage`.
11 changes: 11 additions & 0 deletions contrib/container/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/bash

if [ ! -d /storage/zones ]; then
install -d -o nsd -g nsd -m 775 /storage/zones
fi

if [ ! -f /config/nsd_control.key ]; then
nsd-control-setup
fi

nsd -d $NSD_OPTIONS
11 changes: 11 additions & 0 deletions contrib/container/nsd.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# template nsd.conf for containers

server:
username: nsd
zonesdir: /storage/zones
database: /storage/nsd.db
pidfile: /var/run/nsd.pid

remote-control:
control-enable: yes
control-interface: lo