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-session fcgi curl

RUN ln -s /usr/bin/php84 /usr/bin/php \
    && mkdir -p /var/www/adminer \
    && curl -L https://github.com/vrana/adminer/releases/download/v4.8.1/adminer-4.8.1-mysql-en.php -o /var/www/adminer/index.php

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

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

EXPOSE 9001

ENTRYPOINT ["sh", "setup_adminer.sh"]