#FROM php:7.4.30-fpm-alpine3.15
FROM php:7.4.30-cli-alpine

LABEL maintainer="Ric Harvey <ric@squarecows.com>"

ENV php_conf /usr/local/etc/php-fpm.conf
ENV fpm_conf /usr/local/etc/php-fpm.d/www.conf
ENV php_vars /usr/local/etc/php/conf.d/docker-vars.ini

RUN cd /bin/ && \
wget http://pear.php.net/go-pear.phar -O go-pear.php && \
php go-pear.php


RUN echo @testing http://dl-3.alpinelinux.org/alpine/edge/testing >> /etc/apk/repositories && \
    echo /etc/apk/respositories && \
    apk update && apk upgrade &&\
    apk add --no-cache \
    bash \
    gnu-libiconv \
    openssh-client \
    wget \
    supervisor \
    curl \
    libcurl \
    libpq \
    git \
    python3 \
    py3-pip \
    ca-certificates \
    dialog \
    autoconf \
    make \
    openssl-dev \
    libressl-dev \
    libzip-dev \
    bzip2-dev \
    icu-dev \
    gcc && \
    apk add --no-cache --virtual .sys-deps \
    musl-dev \
    linux-headers \
    augeas-dev \
    libmcrypt-dev \
    libpng-dev \
    libxslt-dev \
    python3-dev \
    libffi-dev \
    freetype-dev \
    sqlite-dev \
    imap-dev \
    libjpeg-turbo-dev \
    postgresql-dev && \
     pip install --upgrade pip && \
    #curl iconv session
    docker-php-ext-install bcmath  pdo_mysql mysqli  pdo_sqlite pgsql pdo_pgsql exif intl  soap zip && \
    pecl install mongodb  && \
    echo "extension=mongodb.so" > /usr/local/etc/php/conf.d/mongodb.ini && \
    pecl install xdebug-3.1.4 && \
    pecl install -o -f redis && \
    echo "extension=redis.so" > /usr/local/etc/php/conf.d/redis.ini && \
    docker-php-source delete && \
    mkdir -p /etc/nginx && \
    mkdir -p /var/www/app && \
    mkdir -p /run/nginx && \
    mkdir -p /var/log/supervisor && \
    php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');" && \
    php composer-setup.php --quiet --install-dir=/usr/bin --filename=composer && \
    rm composer-setup.php &&\
  #  pip3 install -U pip && \
    pip3 install -U certbot && \
    mkdir -p /etc/letsencrypt/webrootauth && \
    apk del gcc musl-dev linux-headers libffi-dev augeas-dev python3-dev make autoconf && \
    apk del .sys-deps
#    ln -s /usr/bin/php7 /usr/bin/php






RUN apk add --no-cache supervisor

RUN mkdir -p "/etc/supervisor/logs"



# copy in code
ADD src/ /var/www/html/
ADD errors/ /var/www/errors
ADD conf/supervisord_worker.conf  /etc/supervisor/supervisord.conf



WORKDIR "/var/www/html"

CMD ["/usr/bin/supervisord", "-n", "-c",  "/etc/supervisor/supervisord.conf"]


