Skip to content

Instantly share code, notes, and snippets.

@kconde2
Forked from evansims/Dockerfile
Created July 23, 2022 23:06
Show Gist options
  • Save kconde2/5874b35f61d3609e0acb4a45695201bb to your computer and use it in GitHub Desktop.
Save kconde2/5874b35f61d3609e0acb4a45695201bb to your computer and use it in GitHub Desktop.
Dockerfile: php-fpm 7.4-fpm alpine w/ gd bz2 intl mbstring redis mongodb xdebug opcache
FROM php:7.4-fpm-alpine
WORKDIR "/application"
# Install essential build tools
RUN apk add --no-cache \
git \
yarn \
autoconf \
g++ \
make \
openssl-dev
# Optional, force UTC as server time
RUN echo "UTC" > /etc/timezone
# Install composer
ENV COMPOSER_HOME /composer
ENV PATH ./vendor/bin:/composer/vendor/bin:$PATH
ENV COMPOSER_ALLOW_SUPERUSER 1
RUN curl -s https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin/ --filename=composer
# Setup bzip2 extension
RUN apk add --no-cache \
bzip2-dev \
&& docker-php-ext-install -j$(nproc) bz2 \
&& docker-php-ext-enable bz2 \
&& rm -rf /tmp/*
# Setup GD extension
RUN apk add --no-cache \
freetype \
libjpeg-turbo \
libpng \
freetype-dev \
libjpeg-turbo-dev \
libpng-dev \
&& docker-php-ext-configure gd \
--with-freetype=/usr/include/ \
# --with-png=/usr/include/ \ # No longer necessary as of 7.4; https://github.com/docker-library/php/pull/910#issuecomment-559383597
--with-jpeg=/usr/include/ \
&& docker-php-ext-install -j$(nproc) gd \
&& docker-php-ext-enable gd \
&& apk del --no-cache \
freetype-dev \
libjpeg-turbo-dev \
libpng-dev \
&& rm -rf /tmp/*
# Install intl extension
RUN apk add --no-cache \
icu-dev \
&& docker-php-ext-install -j$(nproc) intl \
&& docker-php-ext-enable intl \
&& rm -rf /tmp/*
# Install mbstring extension
RUN apk add --no-cache \
oniguruma-dev \
&& docker-php-ext-install mbstring \
&& docker-php-ext-enable mbstring \
&& rm -rf /tmp/*
# INstall opcache, xdebug, redis, mongodb
RUN docker-php-source extract \
&& pecl install opcache xdebug redis mongodb apcu \
&& echo "xdebug.remote_enable=on\n" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini \
&& echo "xdebug.remote_autostart=on\n" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini \
&& echo "xdebug.remote_port=9000\n" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini \
&& echo "xdebug.remote_handler=dbgp\n" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini \
&& echo "xdebug.remote_connect_back=1\n" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini \
&& docker-php-ext-enable opcache xdebug redis mongodb apcu \
&& docker-php-source delete \
&& rm -rf /tmp/*
ENTRYPOINT ['php-fpm']
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment