FROM nginx:alpine

RUN apk add --no-cache certbot openssl

COPY index.html /usr/share/nginx/html/index.html
COPY css /usr/share/nginx/html/css
COPY js /usr/share/nginx/html/js
COPY nginx.conf /etc/nginx/default.conf.template
COPY docker-entrypoint.d/01-render-nginx-conf.sh /docker-entrypoint.d/01-render-nginx-conf.sh
COPY docker-entrypoint.d/05-init-self-signed.sh /docker-entrypoint.d/05-init-self-signed.sh
COPY docker-entrypoint.d/10-certbot-loop.sh /docker-entrypoint.d/10-certbot-loop.sh

RUN chmod +x /docker-entrypoint.d/01-render-nginx-conf.sh \
    /docker-entrypoint.d/05-init-self-signed.sh \
    /docker-entrypoint.d/10-certbot-loop.sh \
    && rm -f /etc/nginx/conf.d/default.conf

EXPOSE 80 443
