FROM composer:latest AS composer-image

FROM php:7.4-fpm-alpine

COPY --from=composer-image /usr/bin/composer /usr/local/bin/composer

RUN ln -s /usr/share/zoneinfo/$TZ /etc/localtime

RUN echo "https://dl-cdn.alpinelinux.org/alpine/v3.16/community"  >> /etc/apk/repositories

RUN apk add --no-cache \
    acl \
    bash \
    curl-dev \
    curl \
    diffutils \
    gettext \
    git \
    icu-dev \
    libsodium-dev \
    libxml2-dev \
    libxslt-dev \
    libzip-dev \
    lz4-dev \
    oniguruma-dev \
    sqlite-dev \
    tzdata \
    unzip \
    vim \
    zstd-dev \
    libjpeg-turbo-dev \
    libpng-dev \
    libwebp-dev \
    freetype-dev \
    libjpeg-turbo \
    libgomp \
    imagemagick-libs \
    imagemagick-dev \
    imagemagick \
    supervisor \
    busybox-suid \
    $PHPIZE_DEPS

RUN docker-php-ext-configure gd --with-jpeg --with-webp --with-freetype &&  \
    docker-php-ext-install -j$(nproc) \
    gd \
    bcmath \
    mbstring \
    simplexml \
    xml \
    intl \
    opcache \
    pcntl \
    pdo \
    pdo_mysql \
    soap \
    sockets \
    sodium \
    xsl \
    zip \
    ctype \
    phar \
    xmlwriter \
#    tokenizer \
    && rm -rf /tmp/* /var/cache/apk/*  \
    && pecl install imagick \
    && docker-php-ext-enable imagick

COPY start.sh /
COPY etc/profile.d/zz-custom.sh /etc/profile.d/zz-custom.sh

RUN sed -i "/history-search-/s/^#//g" /etc/inputrc \
    && sed -i "/export PS1/a export HISTSIZE=10000" /etc/profile

RUN chmod +x /start.sh

EXPOSE 9000

CMD ["/start.sh"]

