Skip to content

Zone-Transfer as Env-Option / Dockerfile correction / docker build . works again / glibc was missing / updated golang image #37

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
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
16 changes: 8 additions & 8 deletions deployment/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
FROM golang:1.20 as builder
FROM golang:1.21.0-bullseye as builder

ENV GO111MODULE=on
ENV GOPATH=/root/go
RUN mkdir -p /root/go/src
COPY dyndns /root/go/src/dyndns
COPY ../dyndns /root/go/src/dyndns
WORKDIR /root/go/src/dyndns
# temp sqlite3 error fix
ENV CGO_CFLAGS "-g -O2 -Wno-return-local-addr"
Expand All @@ -13,18 +13,18 @@ RUN GOOS=linux go build -o /root/go/bin/dyndns && go test -v
FROM debian:11-slim

RUN DEBIAN_FRONTEND=noninteractive apt-get update && \
apt-get install -q -y bind9 dnsutils curl && \
apt-get clean
apt-get install -q -y bind9 dnsutils curl libc6 && \
apt-get clean

RUN chmod 770 /var/cache/bind
COPY deployment/setup.sh /root/setup.sh
COPY setup.sh /root/setup.sh
RUN chmod +x /root/setup.sh
COPY deployment/named.conf.options /etc/bind/named.conf.options
COPY named.conf.options /etc/bind/named.conf.options

WORKDIR /root
COPY --from=builder /root/go/bin/dyndns /root/dyndns
COPY dyndns/views /root/views
COPY dyndns/static /root/static
COPY ../dyndns/views /root/views
COPY ../dyndns/static /root/static

EXPOSE 53 8080
CMD ["sh", "-c", "/root/setup.sh ; service named start ; /root/dyndns"]
1 change: 1 addition & 0 deletions deployment/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ services:
DDNS_DOMAINS: 'dyndns.example.com'
DDNS_PARENT_NS: 'ns.example.com'
DDNS_DEFAULT_TTL: '3600'
DDNS_TRANSFER: 'none'
ports:
- "53:53"
- "53:53/udp"
Expand Down
3 changes: 2 additions & 1 deletion deployment/envfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
DDNS_ADMIN_LOGIN=admin:$$3$$abcdefg
DDNS_DOMAINS=dyndns.example.com
DDNS_PARENT_NS=ns.example.com
DDNS_DEFAULT_TTL=3600
DDNS_DEFAULT_TTL=3600
DDNS_TRANSFER=none
51 changes: 26 additions & 25 deletions deployment/setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,44 +4,45 @@
[ -z "$DDNS_DOMAINS" ] && echo "DDNS_DOMAINS not set" && exit 1;
[ -z "$DDNS_PARENT_NS" ] && echo "DDNS_PARENT_NS not set" && exit 1;
[ -z "$DDNS_DEFAULT_TTL" ] && echo "DDNS_DEFAULT_TTL not set" && exit 1;
[ -z "$DDNS_TRANSFER" ] && echo "DDNS_TRANSFER not set" && exit 1;

DDNS_IP=$(curl icanhazip.com)

for d in ${DDNS_DOMAINS//,/ }
do
if ! grep 'zone "'$d'"' /etc/bind/named.conf > /dev/null
then
echo "creating zone...";
cat >> /etc/bind/named.conf <<EOF
if ! grep 'zone "'$d'"' /etc/bind/named.conf > /dev/null
then
echo "creating zone...";
cat >> /etc/bind/named.conf <<EOF
zone "$d" {
type master;
file "$d.zone";
allow-query { any; };
allow-transfer { none; };
allow-update { localhost; };
type master;
file "$d.zone";
allow-query { any; };
allow-transfer { ${DDNS_TRANSFER}; };
allow-update { localhost; };
};
EOF
fi
fi

if [ ! -f /var/cache/bind/$d.zone ]
then
echo "creating zone file..."
cat > /var/cache/bind/$d.zone <<EOF
if [ ! -f /var/cache/bind/$d.zone ]
then
echo "creating zone file..."
cat > /var/cache/bind/$d.zone <<EOF
\$ORIGIN .
\$TTL 86400 ; 1 day
$d IN SOA ${DDNS_PARENT_NS}. root.${d}. (
74 ; serial
3600 ; refresh (1 hour)
900 ; retry (15 minutes)
604800 ; expire (1 week)
86400 ; minimum (1 day)
)
NS ${DDNS_PARENT_NS}.
A ${DDNS_IP}
\$TTL 86400 ; 1 day
$d IN SOA ${DDNS_PARENT_NS}. root.${d}. (
74 ; serial
3600 ; refresh (1 hour)
900 ; retry (15 minutes)
604800 ; expire (1 week)
86400 ; minimum (1 day)
)
NS ${DDNS_PARENT_NS}.
A ${DDNS_IP}
\$ORIGIN ${d}.
\$TTL ${DDNS_DEFAULT_TTL}
EOF
fi
fi
done

# If /var/cache/bind is a volume, permissions are probably not ok
Expand Down