Skip to content
This repository has been archived by the owner on Sep 8, 2020. It is now read-only.

Commit

Permalink
Use php 7.1
Browse files Browse the repository at this point in the history
  • Loading branch information
jaouadk committed Oct 11, 2017
1 parent 76c1bca commit e048653
Show file tree
Hide file tree
Showing 6 changed files with 55 additions and 54 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
FROM ubuntu:16.04
MAINTAINER Jaouad E. <jaouad.elmoussaoui@gmail.com>
MAINTAINER "https://github.com/shincoder"

ENV DEBIAN_FRONTEND noninteractive

Expand Down
18 changes: 11 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -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:
Expand All @@ -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
Expand Down Expand Up @@ -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=
```
22 changes: 9 additions & 13 deletions docker-compose.dist.yml
Original file line number Diff line number Diff line change
@@ -1,28 +1,24 @@
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 )
- ~/.ssh:/home/homestead/.ssh # Ssh keys for easy deployment inside the container
- ~/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
61 changes: 31 additions & 30 deletions provision.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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 -
Expand Down Expand Up @@ -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;
}
Expand Down
2 changes: 1 addition & 1 deletion serve.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions supervisor.conf
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit e048653

Please sign in to comment.