# Big Breathe — single-container web image for Coolify.
#   nginx 1.x  (static HTML/CSS/JS)
#   php-fpm 8.3 (contact form /api/contact.php)
#   supervisord (PID-1 process manager)

FROM php:8.3-fpm-alpine

RUN apk add --no-cache nginx supervisor curl tini \
    && mkdir -p /run/nginx /var/log/supervisor

COPY infra/nginx.conf       /etc/nginx/nginx.conf
COPY infra/supervisord.conf /etc/supervisord.conf
COPY infra/php-fpm-pool.conf /usr/local/etc/php-fpm.d/zzz-pool.conf

COPY src/index.html              /var/www/html/index.html
COPY src/404.html                /var/www/html/404.html
COPY src/500.html                /var/www/html/500.html
COPY src/robots.txt              /var/www/html/robots.txt
COPY src/sitemap.xml             /var/www/html/sitemap.xml
COPY src/llms.txt                /var/www/html/llms.txt

COPY src/about                   /var/www/html/about/
COPY src/contact                 /var/www/html/contact/
COPY src/services                /var/www/html/services/
COPY src/privacy-policy          /var/www/html/privacy-policy/
COPY src/terms-of-service        /var/www/html/terms-of-service/

COPY src/assets                  /var/www/html/assets/
COPY src/api/contact.php         /var/www/html/api/contact.php

RUN chown -R www-data:www-data /var/www/html

ENV SEND_FROM_EMAIL="" \
    SEND_TO_EMAIL="" \
    SEND_FROM_DOMAIN="" \
    RESEND_API_KEY="" \
    RECAPTCHA_SECRET_KEY="" \
    RATE_LIMIT_PER_IP_PER_10MIN=5 \
    SCORE_PASS=0.7 \
    SCORE_REVIEW=0.4 \
    TIME_MIN_SECONDS=3 \
    TRUST_PROXY=1

EXPOSE 80

HEALTHCHECK --interval=30s --timeout=5s --start-period=10s --retries=3 \
  CMD curl -fsS http://127.0.0.1/index.html > /dev/null || exit 1

ENTRYPOINT ["/sbin/tini", "--"]
CMD ["/usr/bin/supervisord", "-c", "/etc/supervisord.conf", "-n"]
