FROM cznic/knot@sha256:166fd8956f1a69eeb6558c28f65cedb4ea112d4689317f4a50c2f2787ee6a622

RUN apt-get update && apt-get install -y \
    iproute2 \
    iputils-ping \
    net-tools \
    dnsutils \
    procps \
    curl \
    unzip \
    && rm -rf /var/lib/apt/lists/*

# Install bun for the DDNS API simulator
RUN curl -fsSL https://bun.sh/install | bash
ENV PATH="/root/.bun/bin:$PATH"

# The endpoint's own certificate, PRE-INSTALLED the way a real third-party
# service's is (same pattern as the cPanel host sim). The CA rides along so the
# container can probe its own HTTPS endpoint without disabling verification.
COPY config/namecheap/ddns-tls.crt config/namecheap/ddns-tls.key config/namecheap/namecheap-ca.crt /etc/ssl/namecheap-sim/
RUN chmod 600 /etc/ssl/namecheap-sim/ddns-tls.key

COPY simulators/namecheap-ddns/ /simulator/
COPY config/routing/dns-routes.sh /dns-routes.sh
RUN chmod +x /dns-routes.sh

# Custom startup: knot DNS + DDNS simulator
COPY config/routing/namecheap-startup.sh /startup.sh
RUN chmod +x /startup.sh

CMD ["/startup.sh"]
