From e048653621535c15a90b28c2710f957034d0fb2c Mon Sep 17 00:00:00 2001 From: Jaouad E Date: Wed, 11 Oct 2017 12:28:45 +0100 Subject: [PATCH] Use php 7.1 --- Dockerfile | 2 +- README.md | 18 +++++++----- docker-compose.dist.yml | 22 ++++++--------- provision.sh | 61 +++++++++++++++++++++-------------------- serve.sh | 2 +- supervisor.conf | 4 +-- 6 files changed, 55 insertions(+), 54 deletions(-) diff --git a/Dockerfile b/Dockerfile index 8ac7ab8..2b7cfef 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,5 @@ FROM ubuntu:16.04 -MAINTAINER Jaouad E. +MAINTAINER "https://github.com/shincoder" ENV DEBIAN_FRONTEND noninteractive diff --git a/README.md b/README.md index 6e0faed..6853568 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,6 @@ # Laravel homestead-docker -Create a homestead docker container for your development env. ( files taken from laravel settler: provision.sh (modified) + serve.sh ) +Create a homestead docker container for your development env. +(Adapted from laravel homestead provisionning script) ### Install docker && docker compose please refer to these tutorials: @@ -9,7 +10,7 @@ curl -sSL https://get.docker.com/ | sh ``` * install docker compose (https://docs.docker.com/compose/install/) ```shell -curl -L https://github.com/docker/compose/releases/download/1.6.0/docker-compose-`uname -s`-`uname -m` > /usr/local/bin/docker-compose +curl -L https://github.com/docker/compose/releases/download/1.16.1/docker-compose-`uname -s`-`uname -m` > /usr/local/bin/docker-compose ``` ### Pull homestead image @@ -48,10 +49,13 @@ In the host, update ``` /etc/hosts ``` to include your app domain: ``` ### That's it -Our web container starts nginx, php-fpm, redis, beanstalk. and has gruntjs, gulp, bower...etc -some relevant ports have been added to docker-compose.yml ( livereload standard port, karma server port ), -change them if you need to. +Our web container starts nginx, php-fpm, redis, beanstalk. and has npm, gulp, bower...etc ### Notes -- Use docker's local IP address to connect to your database. ``` ifconfig ``` to find the IP used (usually 172.17.0.1). -- Databases: by default mariadb is used as a database, but you are free to use any database you want: choose from these excellent images by Tutum: [tutum/mysql](https://github.com/tutumcloud/mysql) or [tutum/postgresql](https://github.com/tutumcloud/postgresql), they expose different environment variables, so don't forget to update your docker-compose file accordingly. +- Since the web and database containers are linked you can use ```mysql``` as the host in your ```.env``` file with an empty password to properly connect to your database. +``` +DB_HOST=mysql +DB_PORT=3306 +DB_USER=root +DB_PASSWORD= +``` diff --git a/docker-compose.dist.yml b/docker-compose.dist.yml index 7709f35..6d53762 100644 --- a/docker-compose.dist.yml +++ b/docker-compose.dist.yml @@ -1,11 +1,9 @@ web: - image: shincoder/homestead:php7.0 - restart: always + image: shincoder/homestead:php7.1 + restart: unless-stopped ports: - "8000:80" # web - "2222:22" # ssh - - "35729:35729" # live reload - - "9876:9876" # karma server volumes: - ~/.composer:/home/homestead/.composer # composer caching - ~/.gitconfig:/home/homestead/.gitconfig # Git configuration ( access alias && config ) @@ -13,16 +11,14 @@ web: - ~/apps:/apps # all apps - ~/apps/volumes/nginx/sites-available:/etc/nginx/sites-available # nginx sites ( in case you recreate the container ) - ~/apps/volumes/nginx/sites-enabled:/etc/nginx/sites-enabled # nginx sites ( in case you recreate the container ) + - ~/volumes/nginx/ssl:/etc/nginx/ssl links: - - mariadb + - mysql -mariadb: - image: tutum/mariadb - restart: always - ports: - - "33060:3306" +mysql: + image: mysql:5.7 + restart: unless-stopped environment: - MARIADB_USER: admin # cannot be changed ( for info. only ) - MARIADB_PASS: root + MYSQL_ALLOW_EMPTY_PASSWORD: 'yes' volumes: - - ~/apps/volumes/mysql:/var/lib/mysql # database files + - ~/volumes/mysql:/var/lib/mysql diff --git a/provision.sh b/provision.sh index 4b617d4..e16c36c 100644 --- a/provision.sh +++ b/provision.sh @@ -41,11 +41,12 @@ usermod -aG www-data homestead ln -sf /usr/share/zoneinfo/UTC /etc/localtime # PHP -apt-get install -y php-cli php-dev php-pear \ -php-mysql php-pgsql php-sqlite3 php-soap \ -php-apcu php-json php-curl php-gd \ -php-gmp php-imap php-mcrypt php-xdebug \ -php-memcached php-redis php-mbstring php-zip +apt-get install -y php7.1-cli php7.1-dev \ +php7.1-mysql php7.1-pgsql php7.1-sqlite3 php7.1-soap \ +php7.1-json php7.1-curl php7.1-gd \ +php7.1-gmp php7.1-imap php7.1-mcrypt php-xdebug \ +php7.1-mbstring php7.1-zip \ +php-pear php-apcu php-memcached php-redis # Nginx & PHP-FPM apt-get install -y nginx php-fpm @@ -66,26 +67,26 @@ su homestead <<'EOF' EOF # Set Some PHP CLI Settings -sed -i "s/error_reporting = .*/error_reporting = E_ALL/" /etc/php/7.0/cli/php.ini -sed -i "s/display_errors = .*/display_errors = On/" /etc/php/7.0/cli/php.ini -sed -i "s/memory_limit = .*/memory_limit = 512M/" /etc/php/7.0/cli/php.ini -sed -i "s/;date.timezone.*/date.timezone = UTC/" /etc/php/7.0/cli/php.ini - -sed -i "s/.*daemonize.*/daemonize = no/" /etc/php/7.0/fpm/php-fpm.conf -sed -i "s/error_reporting = .*/error_reporting = E_ALL/" /etc/php/7.0/fpm/php.ini -sed -i "s/display_errors = .*/display_errors = On/" /etc/php/7.0/fpm/php.ini -sed -i "s/;cgi.fix_pathinfo=1/cgi.fix_pathinfo=0/" /etc/php/7.0/fpm/php.ini -sed -i "s/memory_limit = .*/memory_limit = 512M/" /etc/php/7.0/fpm/php.ini -sed -i "s/;date.timezone.*/date.timezone = UTC/" /etc/php/7.0/fpm/php.ini +sed -i "s/error_reporting = .*/error_reporting = E_ALL/" /etc/php/7.1/cli/php.ini +sed -i "s/display_errors = .*/display_errors = On/" /etc/php/7.1/cli/php.ini +sed -i "s/memory_limit = .*/memory_limit = 512M/" /etc/php/7.1/cli/php.ini +sed -i "s/;date.timezone.*/date.timezone = UTC/" /etc/php/7.1/cli/php.ini + +sed -i "s/.*daemonize.*/daemonize = no/" /etc/php/7.1/fpm/php-fpm.conf +sed -i "s/error_reporting = .*/error_reporting = E_ALL/" /etc/php/7.1/fpm/php.ini +sed -i "s/display_errors = .*/display_errors = On/" /etc/php/7.1/fpm/php.ini +sed -i "s/;cgi.fix_pathinfo=1/cgi.fix_pathinfo=0/" /etc/php/7.1/fpm/php.ini +sed -i "s/memory_limit = .*/memory_limit = 512M/" /etc/php/7.1/fpm/php.ini +sed -i "s/;date.timezone.*/date.timezone = UTC/" /etc/php/7.1/fpm/php.ini # Enable Remote xdebug -echo "xdebug.remote_enable = 1" >> /etc/php/7.0/fpm/conf.d/20-xdebug.ini -echo "xdebug.remote_connect_back = 1" >> /etc/php/7.0/fpm/conf.d/20-xdebug.ini -echo "xdebug.remote_port = 9000" >> /etc/php/7.0/fpm/conf.d/20-xdebug.ini -echo "xdebug.var_display_max_depth = -1" >> /etc/php/7.0/fpm/conf.d/20-xdebug.ini -echo "xdebug.var_display_max_children = -1" >> /etc/php/7.0/fpm/conf.d/20-xdebug.ini -echo "xdebug.var_display_max_data = -1" >> /etc/php/7.0/fpm/conf.d/20-xdebug.ini -echo "xdebug.max_nesting_level = 500" >> /etc/php/7.0/fpm/conf.d/20-xdebug.ini +echo "xdebug.remote_enable = 1" >> /etc/php/7.1/fpm/conf.d/20-xdebug.ini +echo "xdebug.remote_connect_back = 1" >> /etc/php/7.1/fpm/conf.d/20-xdebug.ini +echo "xdebug.remote_port = 9000" >> /etc/php/7.1/fpm/conf.d/20-xdebug.ini +echo "xdebug.var_display_max_depth = -1" >> /etc/php/7.1/fpm/conf.d/20-xdebug.ini +echo "xdebug.var_display_max_children = -1" >> /etc/php/7.1/fpm/conf.d/20-xdebug.ini +echo "xdebug.var_display_max_data = -1" >> /etc/php/7.1/fpm/conf.d/20-xdebug.ini +echo "xdebug.max_nesting_level = 500" >> /etc/php/7.1/fpm/conf.d/20-xdebug.ini # Not xdebug when on cli phpdismod -s cli xdebug @@ -96,12 +97,12 @@ sed -i "s/user www-data;/user homestead;/" /etc/nginx/nginx.conf sed -i "s/# server_names_hash_bucket_size.*/server_names_hash_bucket_size 64;/" /etc/nginx/nginx.conf mkdir -p /run/php -touch /run/php/php7.0-fpm.sock -sed -i "s/user = www-data/user = homestead/" /etc/php/7.0/fpm/pool.d/www.conf -sed -i "s/group = www-data/group = homestead/" /etc/php/7.0/fpm/pool.d/www.conf -sed -i "s/;listen\.owner.*/listen.owner = homestead/" /etc/php/7.0/fpm/pool.d/www.conf -sed -i "s/;listen\.group.*/listen.group = homestead/" /etc/php/7.0/fpm/pool.d/www.conf -sed -i "s/;listen\.mode.*/listen.mode = 0666/" /etc/php/7.0/fpm/pool.d/www.conf +touch /run/php/php7.1-fpm.sock +sed -i "s/user = www-data/user = homestead/" /etc/php/7.1/fpm/pool.d/www.conf +sed -i "s/group = www-data/group = homestead/" /etc/php/7.1/fpm/pool.d/www.conf +sed -i "s/;listen\.owner.*/listen.owner = homestead/" /etc/php/7.1/fpm/pool.d/www.conf +sed -i "s/;listen\.group.*/listen.group = homestead/" /etc/php/7.1/fpm/pool.d/www.conf +sed -i "s/;listen\.mode.*/listen.mode = 0666/" /etc/php/7.1/fpm/pool.d/www.conf # Install Node curl --silent --location https://deb.nodesource.com/setup_6.x | bash - @@ -152,7 +153,7 @@ block="server { location ~ \.php$ { fastcgi_split_path_info ^(.+\.php)(/.+)$; - fastcgi_pass unix:/run/php/php7.0-fpm.sock; + fastcgi_pass unix:/run/php/php7.1-fpm.sock; fastcgi_index index.php; include fastcgi.conf; } diff --git a/serve.sh b/serve.sh index 9a771a1..17e4e8f 100644 --- a/serve.sh +++ b/serve.sh @@ -25,7 +25,7 @@ block="server { location ~ \.php$ { fastcgi_split_path_info ^(.+\.php)(/.+)$; - fastcgi_pass unix:/run/php/php7.0-fpm.sock; + fastcgi_pass unix:/run/php/php7.1-fpm.sock; fastcgi_index index.php; # include fastcgi_params; include fastcgi.conf; diff --git a/supervisor.conf b/supervisor.conf index 9c51ff3..d7dcca6 100644 --- a/supervisor.conf +++ b/supervisor.conf @@ -6,8 +6,8 @@ command=/usr/sbin/sshd -D autostart=true autorestart=true -[program:php-fpm7.0] -command=/usr/sbin/php-fpm7.0 +[program:php-fpm7.1] +command=/usr/sbin/php-fpm7.1 autostart=true autorestart=true