FROM debian:bullseye-slim

RUN apt update && apt install -y bash cron python3 python3-venv procps tini

RUN python3 -m venv /opt/certbot/ && /opt/certbot/bin/pip install --upgrade pip

RUN /opt/certbot/bin/pip install certbot certbot-dns-cloudflare && \
    ln -s /opt/certbot/bin/certbot /usr/bin/certbot

RUN mkdir -p /config

COPY run.sh / renew.sh /

RUN chmod +x /run.sh /renew.sh

ENV DOMAINS=
ENV EMAIL=
ENV INTERVAL="0 */6 * * *"
ENV STAGING=false
ENV PROPOGATION_TIME=10
ENV GENERATE_DHPARAM=true

ENTRYPOINT ["/usr/bin/tini", "-s", "/run.sh"]