forked from faakit/bet-blocker-dns
-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
171 lines (147 loc) · 5.52 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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
FROM debian:bookworm AS openssl
LABEL maintainer="Matthew Vance"
ENV VERSION_OPENSSL=openssl-3.3.2 \
SHA256_OPENSSL=2e8a40b01979afe8be0bbfb3de5dc1c6709fedb46d6c89c10da114ab5fc3d281 \
SOURCE_OPENSSL=https://www.openssl.org/source/ \
# OpenSSL OMC
OPGP_OPENSSL_1=EFC0A467D613CB83C7ED6D30D894E2CE8B3D79F5 \
# Richard Levitte
OPGP_OPENSSL_2=7953AC1FBC3DC8B3B292393ED5E9E43F7DF9EE8C \
# Matt Caswell
OPGP_OPENSSL_3=8657ABB260F056B1E5190839D9C4D26D0E604491 \
# Paul Dale
OPGP_OPENSSL_4=B7C1C14360F353A36862E4D5231C84CDDCC69C45 \
# Tomas Mraz
OPGP_OPENSSL_5=A21FAB74B0088AA361152586B8EF1A6BA9DA2D5C \
# Tim Hudson
OPGP_OPENSSL_6=C1F33DD8CE1D4CC613AF14DA9195C48241FBF7DD \
# Kurt Roeckx
OPGP_OPENSSL_7=E5E52560DD91C556DDBDA5D02064C53641C25E5D \
# OpenSSL
OPGP_OPENSSL_8=BA5473A2B0587B07FB27CF2D216094DFD0CB81EF
WORKDIR /tmp/src
RUN set -e -x && \
build_deps="build-essential ca-certificates curl dirmngr gnupg libidn2-0-dev libssl-dev" && \
DEBIAN_FRONTEND=noninteractive apt-get update && apt-get install -y --no-install-recommends \
$build_deps && \
curl -L $SOURCE_OPENSSL$VERSION_OPENSSL.tar.gz -o openssl.tar.gz && \
echo "${SHA256_OPENSSL} ./openssl.tar.gz" | sha256sum -c - && \
curl -L $SOURCE_OPENSSL$VERSION_OPENSSL.tar.gz.asc -o openssl.tar.gz.asc && \
GNUPGHOME="$(mktemp -d)" && \
export GNUPGHOME && \
gpg --no-tty --keyserver keyserver.ubuntu.com --recv-keys "$OPGP_OPENSSL_1" "$OPGP_OPENSSL_2" "$OPGP_OPENSSL_3" "$OPGP_OPENSSL_4" "$OPGP_OPENSSL_5" "$OPGP_OPENSSL_6" "$OPGP_OPENSSL_7" "$OPGP_OPENSSL_8" && \
gpg --batch --verify openssl.tar.gz.asc openssl.tar.gz && \
tar xzf openssl.tar.gz && \
cd $VERSION_OPENSSL && \
./config \
--prefix=/opt/openssl \
--openssldir=/opt/openssl \
no-weak-ssl-ciphers \
no-ssl3 \
no-shared \
enable-ec_nistp_64_gcc_128 \
-DOPENSSL_NO_HEARTBEATS \
-fstack-protector-strong && \
make depend && \
nproc | xargs -I % make -j% && \
make install_sw && \
apt-get purge -y --auto-remove \
$build_deps && \
rm -rf \
/tmp/* \
/var/tmp/* \
/var/lib/apt/lists/*
FROM debian:bookworm AS unbound
LABEL maintainer="Matthew Vance"
ENV NAME=unbound \
UNBOUND_VERSION=1.22.0 \
UNBOUND_SHA256=c5dd1bdef5d5685b2cedb749158dd152c52d44f65529a34ac15cd88d4b1b3d43 \
UNBOUND_DOWNLOAD_URL=https://nlnetlabs.nl/downloads/unbound/unbound-1.22.0.tar.gz
WORKDIR /tmp/src
COPY --from=openssl /opt/openssl /opt/openssl
RUN build_deps="curl gcc libc-dev libevent-dev libexpat1-dev libnghttp2-dev make" && \
set -x && \
DEBIAN_FRONTEND=noninteractive apt-get update && apt-get install -y --no-install-recommends \
$build_deps \
bsdmainutils \
ca-certificates \
ldnsutils \
libevent-2.1-7 \
libexpat1 \
libprotobuf-c-dev \
protobuf-c-compiler && \
curl -sSL $UNBOUND_DOWNLOAD_URL -o unbound.tar.gz && \
echo "${UNBOUND_SHA256} *unbound.tar.gz" | sha256sum -c - && \
tar xzf unbound.tar.gz && \
rm -f unbound.tar.gz && \
cd unbound-1.22.0 && \
groupadd _unbound && \
useradd -g _unbound -s /dev/null -d /etc _unbound && \
./configure \
--disable-dependency-tracking \
--prefix=/opt/unbound \
--with-pthreads \
--with-username=_unbound \
--with-ssl=/opt/openssl \
--with-libevent \
--with-libnghttp2 \
--enable-dnstap \
--enable-tfo-server \
--enable-tfo-client \
--enable-event-api \
--enable-subnet && \
make install && \
mv /opt/unbound/etc/unbound/unbound.conf /opt/unbound/etc/unbound/unbound.conf.example && \
apt-get purge -y --auto-remove \
$build_deps && \
rm -rf \
/opt/unbound/share/man \
/tmp/* \
/var/tmp/* \
/var/lib/apt/lists/*
FROM debian:bookworm
LABEL maintainer="Matthew Vance"
ENV NAME=unbound \
SUMMARY="${NAME} is a validating, recursive, and caching DNS resolver." \
DESCRIPTION="${NAME} is a validating, recursive, and caching DNS resolver."
WORKDIR /tmp/src
COPY --from=unbound /opt /opt
RUN set -x && \
DEBIAN_FRONTEND=noninteractive apt-get update && apt-get install -y --no-install-recommends \
bsdmainutils \
ca-certificates \
ldnsutils \
libevent-2.1-7 \
libnghttp2-14 \
libexpat1 \
libprotobuf-c1 && \
groupadd _unbound && \
useradd -g _unbound -s /dev/null -d /etc _unbound && \
apt-get purge -y --auto-remove \
$build_deps && \
rm -rf \
/opt/unbound/share/man \
/tmp/* \
/var/tmp/* \
/var/lib/apt/lists/*
COPY data/ /
# Add this line to copy the Python script into the container
COPY /generate_unbound_conf.py /usr/local/bin/generate_unbound_conf.py
COPY /blocks.txt /usr/local/bin/blocks.txt
# Ensure Python is installed
RUN apt-get update && apt-get install -y --no-install-recommends python3 && \
rm -rf /var/lib/apt/lists/*
RUN chmod +x /unbound.sh
WORKDIR /opt/unbound/
ENV PATH /opt/unbound/sbin:"$PATH"
LABEL org.opencontainers.image.version=${UNBOUND_VERSION} \
org.opencontainers.image.title="mvance/unbound" \
org.opencontainers.image.description="a validating, recursive, and caching DNS resolver" \
org.opencontainers.image.url="https://github.com/MatthewVance/unbound-docker" \
org.opencontainers.image.vendor="Matthew Vance" \
org.opencontainers.image.licenses="MIT" \
org.opencontainers.image.source="https://github.com/MatthewVance/unbound-docker"
EXPOSE 53/tcp
EXPOSE 53/udp
HEALTHCHECK --interval=30s --timeout=30s --start-period=10s --retries=3 CMD drill @127.0.0.1 cloudflare.com || exit 1
CMD ["/unbound.sh"]