FROM nginx:1.21.4
# TODO: use renovate-bot to send pull requests on upstream image updates

RUN mkdir /etc/nginx/templates.override
COPY nginx.conf /etc/nginx/templates.override/default.conf.template

# goenvtemplator2 for config file updates, working around msmtp's inability to
# configure itself from environment variables.
# nginx includes gettext's envsubst, which is generall is more common, but it
# doesn't support conditionals, or even the "default" syntax ${FOO:+default}
ADD https://github.com/seznam/goenvtemplator/releases/download/v2.0.0/goenvtemplator2-amd64 /usr/local/bin/goenvtemplator2
RUN chmod +x /usr/local/bin/goenvtemplator2

COPY entrypoint.sh /usr/local/bin/entrypoint.sh
RUN chmod +x /usr/local/bin/entrypoint.sh
ENTRYPOINT [ "/usr/local/bin/entrypoint.sh" ]
CMD ["nginx", "-g", "daemon off;"]