FROM nginx

########################################
# APT local cache
# work around because COPY failed if no source file
COPY .dummy .apt-mirror-confi[g] .proxy-confi[g] /
RUN cp /.proxy-config /etc/profile.d/proxy.sh 2> /dev/null || true
RUN if [ -f /.apt-mirror-config ] ; then . /.apt-mirror-config && sed -i \
    -e "s/deb.debian.org/${APT_MIRROR_DEBIAN}/g" \
    -e "s/security.debian.org/${APT_MIRROR_DEBIAN_SECURITY}/g" \
    -e "s/archive.ubuntu.com/${APT_MIRROR_UBUNTU}/g" \
    -e "s/security.ubuntu.com/${APT_MIRROR_UBUNTU_SECURITY}/g" \
    /etc/apt/sources.list; fi

########################################
RUN apt-get update --quiet && apt-get upgrade -y

RUN apt install -y python3 python3-venv libaugeas0
RUN python3 -m venv /opt/certbot/
RUN /opt/certbot/bin/python -m pip install --upgrade pip
RUN /opt/certbot/bin/python -m pip install certbot certbot-nginx
RUN ln -s /opt/certbot/bin/certbot /usr/bin/certbot