FROM alpine:3.21.2

LABEL org.opencontainers.image.authors="alier@student.42mulhouse.fr"

RUN apk add php84 php84-phar php84-fpm php84-mysqli php84-iconv php84-curl php84-dom php84-exif \
    php84-fileinfo php84-pecl-imagick php84-mbstring php84-zip php84-gd php84-intl php84-tokenizer fcgi curl

RUN ln -s /usr/bin/php84 /usr/bin/php && \
    curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar && \
    chmod +x wp-cli.phar && \
    mv wp-cli.phar /usr/local/bin/wp

COPY tools/setup_wordpress.sh /setup_wordpress.sh
COPY conf/www.conf /etc/php84/php-fpm.d/www.conf
COPY conf/php.ini /etc/php84/php.ini

HEALTHCHECK --start-period=5s \
    CMD cgi-fcgi -bind -connect 127.0.0.1:9000 || exit 1

EXPOSE 9000

ENTRYPOINT ["sh", "setup_wordpress.sh"]
