Created
February 13, 2017 13:03
-
-
Save shmaltorhbooks/9a9c6b3a9c8fbf57dbf077117327bd39 to your computer and use it in GitHub Desktop.
Docker config for PHP 7.1 with composer, redis and xdebug
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
mkdir -p {logs,cache} && chmod -R a+w {logs,cache} && chown -R www-data:www-data {logs,cache} | |
if [ "$SYMFONY__ENV" = prod ]; then | |
# disable xdebug on "prod" environment | |
unlink /usr/local/etc/php/conf.d/xdebug.ini; | |
fi | |
composer install --optimize-autoloader --no-suggest | |
php bin/console cache:clear -e $SYMFONY__ENV | |
php bin/console doctrine:migrations:status --show-versions | |
php bin/console doctrine:migrations:migrate --no-interaction --allow-no-migration --query-time | |
chmod -R a+w {logs,cache} | |
php-fpm |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM php:7.1-fpm | |
ENV DEBIAN_FRONTEND noninteractive | |
RUN TERM=xterm | |
RUN export TERM=xterm | |
RUN echo 'PS1="\[\033[36m\]\u\[\033[m\]@\[\033[95;1m\]docker-application:\[\033[34m\]\w\[\033[m\]\$ "' >> ~/.bashrc | |
RUN echo "alias console='php bin/console'" >> ~/.bashrc | |
RUN echo "alias phpunit='php bin/phpunit'" >> ~/.bashrc | |
RUN apt-get dist-upgrade -y | |
RUN apt-get update | |
RUN apt-get install -y wget git mc ntp sendmail curl zip libpq-dev libpng12-dev libbz2-dev libsqlite3-dev libcurl4-openssl-dev libicu-dev libldb-dev libldap2-dev libxml2-dev | |
RUN ln -s /usr/lib/x86_64-linux-gnu/libldap.so /usr/lib/libldap.so | |
RUN ln -s /usr/lib/x86_64-linux-gnu/liblber.so /usr/lib/liblber.so | |
RUN docker-php-ext-install pdo_pgsql pgsql gd bcmath bz2 curl intl json ldap pdo_sqlite phar zip xml | |
RUN php -r "readfile('https://getcomposer.org/installer');" | php && chmod +x composer.phar && mv composer.phar /usr/local/bin/composer | |
RUN composer config -g github-oauth.github.com ce3c9b19dc7d59ef066961f3ddc4a1ea2d52126e | |
RUN export PATH="~/.composer/vendor/bin/:$PATH" | |
RUN cd /tmp \ | |
&& wget http://xdebug.org/files/xdebug-2.5.0.tgz \ | |
&& tar -xvzf xdebug-2.5.0.tgz \ | |
&& cd xdebug-2.5.0 \ | |
&& phpize \ | |
&& ./configure \ | |
&& make \ | |
&& make install \ | |
&& echo "zend_extension=$(find /usr/ -name xdebug.so)" > /usr/local/etc/php/conf.d/xdebug.ini \ | |
&& echo "xdebug.remote_enable=on" >> /usr/local/etc/php/conf.d/xdebug.ini \ | |
&& echo "xdebug.remote_autostart=off" >> /usr/local/etc/php/conf.d/xdebug.ini \ | |
&& echo "xdebug.remote_port=9000" >> /usr/local/etc/php/conf.d/xdebug.ini \ | |
&& echo "xdebug.remote_connect_back=On" >> /usr/local/etc/php/conf.d/xdebug.ini \ | |
&& echo "debug.remote_handler=dbgp" >> /usr/local/etc/php/conf.d/xdebug.ini | |
RUN cd /tmp \ | |
&& git clone https://github.com/phpredis/phpredis.git \ | |
&& cd phpredis \ | |
&& git checkout php7 \ | |
&& phpize \ | |
&& ./configure \ | |
&& make && make install \ | |
&& cd .. && rm -rf phpredis | |
RUN echo "extension=$(php-config --extension-dir)/redis.so" > /usr/local/etc/php/conf.d/redis.ini | |
#+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
WORKDIR /var/www | |
#+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
ADD ./source/ /var/www/ | |
ADD ./www.conf /usr/local/etc/php-fpm.d/ | |
ADD ./docker/docker-entrypoint.sh /docker-entrypoint.sh | |
ENTRYPOINT ["/bin/bash", "/docker-entrypoint.sh"] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment