-
Notifications
You must be signed in to change notification settings - Fork 59
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
132 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,6 @@ FROM debian:12 AS build | |
ENV OBS_REPO=knot-resolver-latest | ||
ENV DISTROTEST_REPO=Debian_12 | ||
|
||
|
||
RUN apt-get update -qq && \ | ||
apt-get -qqq -y install \ | ||
apt-transport-https ca-certificates wget \ | ||
|
@@ -25,10 +24,19 @@ RUN cd /source && \ | |
git submodule update --init --recursive && \ | ||
git config --global user.name "Docker Build" && \ | ||
git config --global user.email docker-build@knot-resolver && \ | ||
\ | ||
# Replace 'knot-resolver' user and group with 'root' | ||
# in meson_options.tx and python/knot_resolver/constants.py. | ||
# This is needed for the file/directory permissions validation | ||
# and then for the proper functioning of the resolver. | ||
sed s/knot-resolver/root/g -i meson_options.txt && \ | ||
sed 's/USER.*/USER = "root"/g' -i python/knot_resolver/constants.py && \ | ||
sed 's/GROUP.*/GROUP = "root"/g' -i python/knot_resolver/constants.py && \ | ||
git commit -a -m TMP && \ | ||
\ | ||
/root/.local/bin/apkg build-dep -y && \ | ||
/root/.local/bin/apkg build | ||
|
||
|
||
# Real container | ||
FROM debian:12-slim AS runtime | ||
|
||
|
@@ -56,16 +64,20 @@ RUN apt-get install -y /pkg/*/*.deb && \ | |
apt-get remove -y -qq curl gnupg2 && \ | ||
apt-get autoremove -y && \ | ||
apt-get clean && \ | ||
rm -rf /var/lib/apt/lists/* && \ | ||
mkdir /config | ||
rm -rf /var/lib/apt/lists/* | ||
|
||
COPY etc/config/config.example.docker.yaml /config/config.yaml | ||
COPY etc/config/config.example.docker.yaml /etc/knot-resolver/config.yaml | ||
|
||
LABEL cz.knot-resolver.vendor="CZ.NIC" | ||
LABEL maintainer="[email protected]" | ||
|
||
# Export plain DNS, DoT, DoH and management interface | ||
EXPOSE 53/UDP 53/TCP 443/TCP 853/TCP 5000/TCP | ||
|
||
# Prepare shared config | ||
VOLUME /etc/knot-resolver | ||
# Prepare shared cache | ||
VOLUME /var/cache/knot-resolver | ||
|
||
ENTRYPOINT ["/usr/bin/knot-resolver"] | ||
CMD ["-c", "/config/config.yaml"] | ||
CMD ["-c", "/etc/knot-resolver/config.yaml"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
# Based on https://netfuture.ch/2020/05/multi-arch-docker-image-easy/ | ||
# | ||
# Example: make -f Makefile.docker docker-multiarch | ||
|
||
REGISTRY = cznic | ||
BASETAG = ${REGISTRY}/knot-resolver | ||
PLATFORMS = linux/amd64,linux/arm/v7,linux/arm64/v8 | ||
|
||
RELEASE = $(shell git describe --abbrev=0 --exact-match) | ||
RELTAG = $(shell [ -n "${RELEASE}" ] && echo "-t ${BASETAG}:${RELEASE}" || echo "") | ||
|
||
BUILDXDETECT = ${HOME}/.docker/cli-plugins/docker-buildx | ||
QEMUDETECT = /proc/sys/fs/binfmt_misc/qemu-m68k | ||
|
||
# https://stackoverflow.com/a/324782 | ||
ROOT_DIR:=$(dir $(realpath $(lastword $(MAKEFILE_LIST))))/.. | ||
|
||
docker-multiarch: qemu buildx docker-multiarch-builder | ||
docker login | ||
docker buildx build --no-cache --builder docker-multiarch --pull --push \ | ||
--platform ${PLATFORMS} ${RELTAG} ${ROOT_DIR} | ||
|
||
qemu: ${QEMUDETECT} | ||
${QEMUDETECT}: | ||
docker pull multiarch/qemu-user-static | ||
docker run --privileged multiarch/qemu-user-static --reset -p yes | ||
docker ps -a | sed -n 's, *multiarch/qemu-user-static.*,,p' \ | ||
| (xargs docker rm 2>&1 || \ | ||
echo "Cannot remove docker container on ZFS; retry after next reboot") \ | ||
| grep -v 'dataset is busy' | ||
|
||
buildx: ${BUILDXDETECT} | ||
${BUILDXDETECT}: | ||
@echo | ||
# Output of `uname -m` is too different | ||
@echo '*** `docker buildx` missing. Install binary for this machine architecture' | ||
@echo '*** from `https://github.com/docker/buildx/releases/latest`' | ||
@echo '*** to `~/.docker/cli-plugins/docker-buildx` and `chmod +x` it.' | ||
@echo | ||
@exit 1 | ||
|
||
docker-multiarch-builder: qemu buildx | ||
if ! docker buildx ls | grep -w docker-multiarch > /dev/null; then \ | ||
docker buildx create --name docker-multiarch && \ | ||
docker buildx inspect --builder docker-multiarch --bootstrap; \ | ||
fi | ||
|
||
.PHONY: qemu buildx docker-multiarch docker-multiarch-builder |