├── .travis.yml ├── LICENCE ├── README.md ├── capistrano └── 3.9 │ └── Dockerfile ├── docker-compose.yml ├── nginx └── 1.13 │ ├── Dockerfile │ └── vhost.conf └── php ├── 7.1 └── Dockerfile ├── 7.2 └── Dockerfile └── 7.3 └── Dockerfile /.travis.yml: -------------------------------------------------------------------------------- 1 | sudo: required 2 | 3 | services: 4 | - docker 5 | 6 | script: 7 | - docker build -t test/php:7.1 php/7.1/ 8 | - docker build -t test/php:7.2 php/7.2/ 9 | - docker build -t test/php:7.3 php/7.3/ 10 | - docker build -t test/nginx:1.13 nginx/1.13/ 11 | - docker build -t test/capistrano:3.9 capistrano/3.9/ 12 | -------------------------------------------------------------------------------- /LICENCE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2017 Julien Guyomard 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Docker Images for Laravel development 2 | [![Docker Build Status](https://img.shields.io/docker/build/jguyomard/laravel-php.svg?style=flat-square)](https://hub.docker.com/r/jguyomard/laravel-php/) 3 | [![Docker Build Status](https://img.shields.io/docker/build/jguyomard/laravel-nginx.svg?style=flat-square)](https://hub.docker.com/r/jguyomard/laravel-nginx/) 4 | [![Docker Build Status](https://img.shields.io/docker/build/jguyomard/laravel-capistrano.svg?style=flat-square)](https://hub.docker.com/r/jguyomard/laravel-capistrano/) 5 | 6 | This repository provides you a development environment without requiring you to install PHP, a web server, and any other server software on your local machine. For this, it requires Docker and Docker Compose. 7 | 8 | 9 | ## Installation 10 | 11 | 1. Install [docker](https://docs.docker.com/engine/installation/) and [docker-compose](https://docs.docker.com/compose/install/) ; 12 | 13 | 2. Copy `docker-compose.yml` file to your project root path, and edit it according to your needs ; 14 | 15 | 3. From your project directory, start up your application by running: 16 | 17 | ```sh 18 | docker-compose up 19 | ``` 20 | 4. If you want, you can run composer or artisan through docker. For instance: 21 | 22 | ```sh 23 | docker-compose exec php composer install 24 | docker-compose exec php php artisan migrate 25 | docker-compose exec php $yourCommandHere 26 | ``` 27 | 28 | 29 | ## Docker Images 30 | 31 | These docker images are configured in `docker-compose.yml` file. 32 | You can comment or uncomment some services according to your project. 33 | 34 | * [`jguyomard/laravel-php:7.3`](https://hub.docker.com/r/jguyomard/laravel-php/) (this docker image extends `php:7.3-fpm-alpine` to add some PHP extensions) ; 35 | * [`jguyomard/laravel-nginx:1.13`](https://hub.docker.com/r/jguyomard/laravel-nginx/) (this docker image extends `nginx:1.13-alpine` to add Laravel vhost) ; 36 | * `mysql:5.7` ; 37 | * `postgres:9.6-alpine` ; 38 | * `redis:4.0-alpine` ; 39 | * `elasticsearch:5.5-alpine`. 40 | 41 | 42 | ## Other tools 43 | 44 | This repository also comes with a caspistrano docker image: [`jguyomard/laravel-capistrano:3.9`](https://hub.docker.com/r/jguyomard/laravel-capistrano/). 45 | 46 | For ease of use, you can create a bash alias: 47 | 48 | ``` 49 | alias cap='docker run --rm --user cap -v "$PWD":/src -v "$(dirname $SSH_AUTH_SOCK)":"$(dirname $SSH_AUTH_SOCK)" -e SSH_AUTH_SOCK="${SSH_AUTH_SOCK}" jguyomard/laravel-capistrano:3.9 cap' 50 | ``` 51 | 52 | 53 | ## Contributing 54 | 55 | Contributions are welcome! 56 | Leave an issue on Github, or create a Pull Request. 57 | 58 | 59 | ## Licence 60 | 61 | This work is under [MIT](LICENCE) licence. 62 | -------------------------------------------------------------------------------- /capistrano/3.9/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM ruby:2.4-alpine 2 | 3 | MAINTAINER JG 4 | 5 | ENV VERSION "~> 3.9.0" 6 | RUN apk add --no-cache git \ 7 | && gem install capistrano -v "${VERSION}" \ 8 | && gem install capistrano-composer \ 9 | && gem install capistrano-laravel \ 10 | && addgroup -Sg 1000 cap \ 11 | && adduser -SG cap -u 1000 -h /src cap 12 | 13 | VOLUME /src 14 | 15 | WORKDIR /src 16 | -------------------------------------------------------------------------------- /docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: '2' 2 | services: 3 | 4 | php: 5 | image: jguyomard/laravel-php:7.3 6 | volumes: 7 | - ./:/var/www/ 8 | - $HOME/.composer/:$HOME/.composer/ 9 | environment: 10 | - "DB_HOST=mysql" 11 | - "DB_DATABASE=homestead" 12 | - "DB_USERNAME=homestead" 13 | - "DB_PASSWORD=homestead" 14 | - "REDIS_HOST=redis" 15 | - "REDIS_PORT=6379" 16 | 17 | nginx: 18 | image: jguyomard/laravel-nginx:1.13 19 | volumes_from: 20 | - php 21 | ports: 22 | - 8080:80 23 | 24 | mysql: 25 | image: mysql:5.7 26 | volumes: 27 | - mysqldata:/var/lib/mysql 28 | environment: 29 | - "MYSQL_ROOT_PASSWORD=secret" 30 | - "MYSQL_DATABASE=homestead" 31 | - "MYSQL_USER=homestead" 32 | - "MYSQL_PASSWORD=homestead" 33 | # ports: 34 | # - "3306:3306" 35 | 36 | # pgsql: 37 | # image: postgres:9.6-alpine 38 | # volumes: 39 | # - pgsqldata:/var/lib/postgresql/data 40 | # environment: 41 | # - "POSTGRES_DB=homestead" 42 | # - "POSTGRES_USER=homestead" 43 | # - "POSTGRES_PASSWORD=homestead" 44 | # ports: 45 | # - "5432:5432" 46 | 47 | redis: 48 | image: redis:4.0-alpine 49 | command: redis-server --appendonly yes 50 | # ports: 51 | # - "6379:6379" 52 | 53 | # elastic: 54 | # image: elasticsearch:5.5-alpine 55 | # ports: 56 | # - "9200:9200" 57 | 58 | volumes: 59 | mysqldata: 60 | pgsqldata: 61 | -------------------------------------------------------------------------------- /nginx/1.13/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM nginx:1.13-alpine 2 | 3 | MAINTAINER JG 4 | 5 | ADD vhost.conf /etc/nginx/conf.d/default.conf 6 | 7 | WORKDIR /var/www 8 | -------------------------------------------------------------------------------- /nginx/1.13/vhost.conf: -------------------------------------------------------------------------------- 1 | server { 2 | listen 80; 3 | index index.php index.html; 4 | root /var/www/public; 5 | client_max_body_size 32M; 6 | 7 | location / { 8 | try_files $uri /index.php?$args; 9 | } 10 | 11 | location ~ \.php$ { 12 | fastcgi_split_path_info ^(.+\.php)(/.+)$; 13 | fastcgi_pass php:9000; 14 | fastcgi_index index.php; 15 | include fastcgi_params; 16 | fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; 17 | fastcgi_param PATH_INFO $fastcgi_path_info; 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /php/7.1/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM php:7.1-fpm-alpine 2 | 3 | MAINTAINER JG 4 | 5 | RUN apk add --no-cache --virtual .build-deps \ 6 | $PHPIZE_DEPS \ 7 | curl-dev \ 8 | imagemagick-dev \ 9 | libmcrypt-dev \ 10 | libtool \ 11 | libxml2-dev \ 12 | postgresql-dev \ 13 | sqlite-dev \ 14 | && apk add --no-cache \ 15 | curl \ 16 | git \ 17 | imagemagick \ 18 | libmcrypt \ 19 | mysql-client \ 20 | postgresql-libs \ 21 | libintl \ 22 | icu \ 23 | icu-dev \ 24 | && pecl install imagick \ 25 | && docker-php-ext-enable imagick \ 26 | && docker-php-ext-install \ 27 | bcmath \ 28 | curl \ 29 | iconv \ 30 | mbstring \ 31 | mcrypt \ 32 | pdo \ 33 | pdo_mysql \ 34 | pdo_pgsql \ 35 | pdo_sqlite \ 36 | pcntl \ 37 | tokenizer \ 38 | xml \ 39 | zip \ 40 | intl \ 41 | && curl -s https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin/ --filename=composer \ 42 | && apk del -f .build-deps 43 | 44 | WORKDIR /var/www 45 | -------------------------------------------------------------------------------- /php/7.2/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM php:7.2-fpm-alpine 2 | 3 | MAINTAINER JG 4 | 5 | RUN apk add --no-cache --virtual .build-deps \ 6 | $PHPIZE_DEPS \ 7 | curl-dev \ 8 | imagemagick-dev \ 9 | libtool \ 10 | libxml2-dev \ 11 | postgresql-dev \ 12 | sqlite-dev \ 13 | && apk add --no-cache \ 14 | curl \ 15 | git \ 16 | imagemagick \ 17 | mysql-client \ 18 | postgresql-libs \ 19 | libintl \ 20 | icu \ 21 | icu-dev \ 22 | && pecl install imagick \ 23 | && docker-php-ext-enable imagick \ 24 | && docker-php-ext-install \ 25 | bcmath \ 26 | curl \ 27 | iconv \ 28 | mbstring \ 29 | pdo \ 30 | pdo_mysql \ 31 | pdo_pgsql \ 32 | pdo_sqlite \ 33 | pcntl \ 34 | tokenizer \ 35 | xml \ 36 | zip \ 37 | intl \ 38 | && curl -s https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin/ --filename=composer \ 39 | && apk del -f .build-deps 40 | 41 | WORKDIR /var/www 42 | -------------------------------------------------------------------------------- /php/7.3/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM php:7.3-fpm-alpine 2 | 3 | MAINTAINER JG 4 | 5 | RUN apk add --no-cache --virtual .build-deps \ 6 | $PHPIZE_DEPS \ 7 | curl-dev \ 8 | imagemagick-dev \ 9 | libtool \ 10 | libxml2-dev \ 11 | postgresql-dev \ 12 | sqlite-dev \ 13 | && apk add --no-cache \ 14 | curl \ 15 | git \ 16 | imagemagick \ 17 | mysql-client \ 18 | postgresql-libs \ 19 | libintl \ 20 | icu \ 21 | icu-dev \ 22 | libzip-dev \ 23 | && pecl install imagick \ 24 | && docker-php-ext-enable imagick \ 25 | && docker-php-ext-install \ 26 | bcmath \ 27 | curl \ 28 | iconv \ 29 | mbstring \ 30 | pdo \ 31 | pdo_mysql \ 32 | pdo_pgsql \ 33 | pdo_sqlite \ 34 | pcntl \ 35 | tokenizer \ 36 | xml \ 37 | zip \ 38 | intl \ 39 | && curl -s https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin/ --filename=composer \ 40 | && apk del -f .build-deps 41 | 42 | WORKDIR /var/www 43 | --------------------------------------------------------------------------------