+ settings php7.4-fpm container.
This commit is contained in:
@ -3,8 +3,9 @@ RUN apt-get update && apt-get install -y \
|
||||
libfreetype6-dev \
|
||||
libjpeg62-turbo-dev \
|
||||
libpng-dev \
|
||||
libwebp-dev \
|
||||
&& docker-php-ext-install -j$(nproc) iconv \
|
||||
&& docker-php-ext-configure gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/ \
|
||||
&& docker-php-ext-configure gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/ --with-webp-dir=/usr/include/ \
|
||||
&& docker-php-ext-install -j$(nproc) gd \
|
||||
&& docker-php-ext-install mysqli \
|
||||
&& docker-php-ext-enable mysqli
|
||||
|
127
dockerfiles/php7.4-fpm/Dockerfile
Normal file
127
dockerfiles/php7.4-fpm/Dockerfile
Normal file
@ -0,0 +1,127 @@
|
||||
FROM php:7.4-fpm
|
||||
RUN apt-get update && apt-get install -y \
|
||||
libfreetype6-dev \
|
||||
libjpeg62-turbo-dev \
|
||||
libpng-dev \
|
||||
libwebp-dev \
|
||||
&& docker-php-ext-install -j$(nproc) iconv \
|
||||
&& docker-php-ext-configure gd --with-freetype --with-jpeg --with-webp \
|
||||
&& docker-php-ext-install -j$(nproc) gd \
|
||||
&& docker-php-ext-install mysqli \
|
||||
&& docker-php-ext-enable mysqli
|
||||
|
||||
RUN apt-get update && docker-php-ext-install pdo pdo_mysql && docker-php-ext-enable pdo pdo_mysql
|
||||
|
||||
###########################################################################
|
||||
# xDebug:
|
||||
###########################################################################
|
||||
|
||||
ARG INSTALL_XDEBUG=false
|
||||
|
||||
RUN if [ ${INSTALL_XDEBUG} = true ]; then \
|
||||
# Install the xdebug extension
|
||||
if [ $(php -r "echo PHP_MAJOR_VERSION;") = "5" ]; then \
|
||||
pecl install xdebug-2.5.5; \
|
||||
else \
|
||||
pecl install xdebug; \
|
||||
fi && \
|
||||
docker-php-ext-enable xdebug && \
|
||||
sed -i 's/^zend_extension=/;zend_extension=/g' /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini \
|
||||
;fi
|
||||
|
||||
# Copy xdebug configuration for remote debugging
|
||||
COPY ./xdebug.ini /usr/local/etc/php/conf.d/xdebug.ini
|
||||
|
||||
RUN sed -i "s/xdebug.remote_autostart=0/xdebug.remote_autostart=1/" /usr/local/etc/php/conf.d/xdebug.ini && \
|
||||
sed -i "s/xdebug.remote_enable=0/xdebug.remote_enable=1/" /usr/local/etc/php/conf.d/xdebug.ini && \
|
||||
sed -i "s/xdebug.cli_color=0/xdebug.cli_color=1/" /usr/local/etc/php/conf.d/xdebug.ini
|
||||
|
||||
|
||||
###########################################################################
|
||||
# Redis and igbinary:
|
||||
###########################################################################
|
||||
|
||||
ARG INSTALL_REDIS=false
|
||||
|
||||
RUN if [ ${INSTALL_REDIS} = true ]; then \
|
||||
pecl install igbinary \
|
||||
&& pecl install -a redis \
|
||||
&& docker-php-ext-enable igbinary redis \
|
||||
;fi
|
||||
|
||||
###########################################################################
|
||||
# Zip:
|
||||
###########################################################################
|
||||
|
||||
ARG INSTALL_ZIP=false
|
||||
|
||||
RUN if [ ${INSTALL_ZIP} = true ]; then \
|
||||
apt update && apt install -y libzip-dev \
|
||||
&& docker-php-ext-install zip \
|
||||
&& docker-php-ext-enable zip \
|
||||
;fi
|
||||
|
||||
###########################################################################
|
||||
# Pear Mail and Mail_Mime:
|
||||
###########################################################################
|
||||
|
||||
ARG INSTALL_PEAR_MAIL=false
|
||||
|
||||
RUN if [ ${INSTALL_PEAR_MAIL} = true ]; then \
|
||||
pear install Mail && pear install Mail_Mime \
|
||||
;fi
|
||||
|
||||
###########################################################################
|
||||
# BZ2 function:
|
||||
###########################################################################
|
||||
|
||||
ARG INSTALL_BZ2=false
|
||||
|
||||
RUN if [ ${INSTALL_BZ2} = true ]; then \
|
||||
apt update && apt install -y libbz2-ocaml-dev \
|
||||
&& docker-php-ext-install bz2 \
|
||||
&& docker-php-ext-enable bz2 \
|
||||
;fi
|
||||
|
||||
###########################################################################
|
||||
# INTL function:
|
||||
###########################################################################
|
||||
|
||||
ARG INSTALL_INTL=false
|
||||
|
||||
RUN if [ ${INSTALL_INTL} = true ]; then \
|
||||
apt update && apt install -y libicu-dev \
|
||||
&& docker-php-ext-install intl \
|
||||
&& docker-php-ext-enable intl \
|
||||
;fi
|
||||
|
||||
###########################################################################
|
||||
# php.ini opts:
|
||||
###########################################################################
|
||||
|
||||
# https://github.com/php/php-src/blob/master/php.ini-development
|
||||
RUN mv "$PHP_INI_DIR/php.ini-development" "$PHP_INI_DIR/php.ini"
|
||||
|
||||
ARG PHP_OPT_SHORT_OPEN_TAG=Off
|
||||
|
||||
RUN sed -i "s/^short_open_tag = .*/short_open_tag = $PHP_OPT_SHORT_OPEN_TAG/g" "$PHP_INI_DIR/php.ini"
|
||||
|
||||
ARG PHP_OPT_MAX_EXECUTION_TIME=30
|
||||
|
||||
RUN sed -i "s/^max_execution_time = .*/max_execution_time = $PHP_OPT_MAX_EXECUTION_TIME/g" "$PHP_INI_DIR/php.ini"
|
||||
|
||||
ARG PHP_OPT_MEMORY_LIMIT=128M
|
||||
|
||||
RUN sed -i "s/^memory_limit = .*/memory_limit = $PHP_OPT_MEMORY_LIMIT/g" "$PHP_INI_DIR/php.ini"
|
||||
|
||||
ARG PHP_OPT_UPLOAD_MAX_FILESIZE=2M
|
||||
|
||||
RUN sed -i "s/^upload_max_filesize = .*/upload_max_filesize = $PHP_OPT_UPLOAD_MAX_FILESIZE/g" "$PHP_INI_DIR/php.ini"
|
||||
|
||||
|
||||
###########################################################################
|
||||
# Prepend nginx 502 on showing errors:
|
||||
# @see https://stackoverflow.com/questions/55260221/laravel-php-7-3-nginx-502-upstream-prematurely-closed-fastcgi-stdout
|
||||
###########################################################################
|
||||
|
||||
RUN sed -i "s/^log_limit = .*/log_limit = 1024/g" "$PHP_INI_DIR/../php-fpm.d/docker.conf"
|
25
dockerfiles/php7.4-fpm/xdebug.ini
Normal file
25
dockerfiles/php7.4-fpm/xdebug.ini
Normal file
@ -0,0 +1,25 @@
|
||||
; NOTE: The actual debug.so extention is NOT SET HERE but rather (/usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini)
|
||||
|
||||
;xdebug.remote_host=dockerhost
|
||||
xdebug.remote_connect_back=1
|
||||
xdebug.remote_port=9000
|
||||
xdebug.idekey=PHPSTORM
|
||||
|
||||
xdebug.remote_autostart=0
|
||||
xdebug.remote_enable=0
|
||||
xdebug.cli_color=0
|
||||
xdebug.profiler_enable=1
|
||||
xdebug.profiler_enable_trigger=1
|
||||
xdebug.profiler_output_dir=/tmp
|
||||
|
||||
xdebug.remote_handler=dbgp
|
||||
xdebug.remote_mode=req
|
||||
|
||||
xdebug.var_display_max_children=-1
|
||||
xdebug.var_display_max_data=-1
|
||||
xdebug.var_display_max_depth=-1
|
||||
|
||||
xdebug.trace_enable_trigger=1
|
||||
xdebug.trace_output_dir=/tmp
|
||||
xdebug.trace_output_name="trace.%t"
|
||||
|
101
dockerfiles/php7.4-fpm/xdebug.sh
Executable file
101
dockerfiles/php7.4-fpm/xdebug.sh
Executable file
@ -0,0 +1,101 @@
|
||||
#! /bin/bash
|
||||
|
||||
# NOTE: At the moment, this has only been confirmed to work with PHP 7
|
||||
|
||||
|
||||
# Grab full name of php-fpm container
|
||||
PHP_FPM_CONTAINER=$(docker ps | grep php-fpm | awk '{print $1}')
|
||||
|
||||
|
||||
# Grab OS type
|
||||
if [[ "$(uname)" == "Darwin" ]]; then
|
||||
OS_TYPE="OSX"
|
||||
else
|
||||
OS_TYPE=$(expr substr $(uname -s) 1 5)
|
||||
fi
|
||||
|
||||
|
||||
xdebug_status ()
|
||||
{
|
||||
echo 'xDebug status'
|
||||
|
||||
# If running on Windows, need to prepend with winpty :(
|
||||
if [[ $OS_TYPE == "MINGW" ]]; then
|
||||
winpty docker exec -it $PHP_FPM_CONTAINER bash -c 'php -v'
|
||||
|
||||
else
|
||||
docker exec -it $PHP_FPM_CONTAINER bash -c 'php -v'
|
||||
fi
|
||||
|
||||
}
|
||||
|
||||
|
||||
xdebug_start ()
|
||||
{
|
||||
echo 'Start xDebug'
|
||||
|
||||
# And uncomment line with xdebug extension, thus enabling it
|
||||
ON_CMD="sed -i 's/^;zend_extension=/zend_extension=/g' \
|
||||
/usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini"
|
||||
|
||||
|
||||
# If running on Windows, need to prepend with winpty :(
|
||||
if [[ $OS_TYPE == "MINGW" ]]; then
|
||||
winpty docker exec -it $PHP_FPM_CONTAINER bash -c "${ON_CMD}"
|
||||
docker restart $PHP_FPM_CONTAINER
|
||||
winpty docker exec -it $PHP_FPM_CONTAINER bash -c 'php -v'
|
||||
|
||||
else
|
||||
docker exec -it $PHP_FPM_CONTAINER bash -c "${ON_CMD}"
|
||||
docker restart $PHP_FPM_CONTAINER
|
||||
docker exec -it $PHP_FPM_CONTAINER bash -c 'php -v'
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
xdebug_stop ()
|
||||
{
|
||||
echo 'Stop xDebug'
|
||||
|
||||
# Comment out xdebug extension line
|
||||
OFF_CMD="sed -i 's/^zend_extension=/;zend_extension=/g' /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini"
|
||||
|
||||
|
||||
# If running on Windows, need to prepend with winpty :(
|
||||
if [[ $OS_TYPE == "MINGW" ]]; then
|
||||
# This is the equivalent of:
|
||||
# winpty docker exec -it laradock_php-fpm_1 bash -c 'bla bla bla'
|
||||
# Thanks to @michaelarnauts at https://github.com/docker/compose/issues/593
|
||||
winpty docker exec -it $PHP_FPM_CONTAINER bash -c "${OFF_CMD}"
|
||||
docker restart $PHP_FPM_CONTAINER
|
||||
#docker-compose restart php-fpm
|
||||
winpty docker exec -it $PHP_FPM_CONTAINER bash -c 'php -v'
|
||||
|
||||
else
|
||||
docker exec -it $PHP_FPM_CONTAINER bash -c "${OFF_CMD}"
|
||||
# docker-compose restart php-fpm
|
||||
docker restart $PHP_FPM_CONTAINER
|
||||
docker exec -it $PHP_FPM_CONTAINER bash -c 'php -v'
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
case $@ in
|
||||
stop|STOP)
|
||||
xdebug_stop
|
||||
;;
|
||||
start|START)
|
||||
xdebug_start
|
||||
;;
|
||||
status|STATUS)
|
||||
xdebug_status
|
||||
;;
|
||||
*)
|
||||
echo "xDebug [Stop | Start | Status] in the ${PHP_FPM_CONTAINER} container."
|
||||
echo "xDebug must have already been installed."
|
||||
echo "Usage:"
|
||||
echo " .php-fpm/xdebug stop|start|status"
|
||||
|
||||
esac
|
||||
|
||||
exit 1
|
Reference in New Issue
Block a user