├── .gitignore ├── README.md ├── docker-compose.yml └── sites └── default /.gitignore: -------------------------------------------------------------------------------- 1 | www/default 2 | database 3 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ## alpine-nginx-php-mariadb 2 | A slightly opinionated minimal development environment for PHP/Laravel, built with: 3 | 4 | * Alpine Linux 5 | * Nginx 1.8.0 6 | * PHP 5.6 7 | * MariaDB 5.5 8 | 9 | ## Usage 10 | * clone this repo: `git clone https://github.com/dydx/alpine-nginx-php-mariadb` 11 | * cd in: `cd alpine-nginx-php-mariadb` 12 | * build/run it: `docker-compose up -d` 13 | 14 | ## Connections 15 | MariaDB is linked as `mysql`, just reference this in your database connection config. The credentials are identical to Laravel Homestead's: 16 | 17 | * database: homestead 18 | * username: homestead 19 | * password: secret 20 | 21 | ## Running Artisan migrations and seeds 22 | I'm still working on a more efficient way to do this, but currently, you have to do this to run artisan: 23 | 24 | * attach to the nginx container: `docker exec -it alpinenginxphpmariadb_front_1 /bin/sh` 25 | * cd to the web root: `cd /var/www/default` 26 | * run your migrations/seeds: `php artisan migrate` or `php artisan db:seed` 27 | 28 | ## Data locations and persistence 29 | MySQL is persisted to the host in the `database` directory, Nginx's default vhost is stored at `sites/default`, and your http docs are stored in `www/default`. 30 | 31 | The setup is a little opinionated for Laravel development; the current Nginx vhost has `/var/www/default/public` as its doc root. You can obviously change this for your needs. 32 | 33 | ## size 34 | I wanted these containers to be pretty small, considering that my main workstation is an Acer C720 with the 16Gb SSD (running Elementary OS). On my machine, here are the image virtual sizes: 35 | 36 | * front: 70.05 MB 37 | * mysql: 199.5 MB 38 | 39 | I think this is considerably smaller than the setup I had with [kasperisager's](https://github.com/kasperisager) excellent [phpstack](https://github.com/kasperisager/phpstack). There isn't anything inherently wrong with his setup (it actually has a lot more features baked in), but it was cramping my laptop up quite a bit. 40 | 41 | ## TODO 42 | I'm considering adding in Composer, PHPUnit, NodeJS/Gulp/Bower for doing *all* of the development related tasks in the nginx container, but I'm unsure just how necessary that is. 43 | -------------------------------------------------------------------------------- /docker-compose.yml: -------------------------------------------------------------------------------- 1 | front: 2 | image: dydx/alpine-nginx-phpfpm 3 | ports: 4 | - "80:80" 5 | volumes: 6 | - ./www:/var/www 7 | - ./sites:/etc/nginx/sites-enabled 8 | links: 9 | - mysql:mysql 10 | 11 | mysql: 12 | image: dydx/alpine-mariadb 13 | ports: 14 | - "3306:3306" 15 | volumes: 16 | - ./database:/var/lib/mysql 17 | -------------------------------------------------------------------------------- /sites/default: -------------------------------------------------------------------------------- 1 | server { 2 | server_name default; 3 | root /var/www/default/public; 4 | index index.php; 5 | 6 | client_max_body_size 100M; 7 | fastcgi_read_timeout 1800; 8 | 9 | location / { 10 | try_files $uri $uri/ /index.php$query_string; 11 | } 12 | 13 | location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ { 14 | expires max; 15 | log_not_found off; 16 | access_log off; 17 | } 18 | 19 | location ~ \.php$ { 20 | try_files $uri =404; 21 | include fastcgi_params; 22 | fastcgi_index index.php; 23 | fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; 24 | fastcgi_pass 127.0.0.1:9000; 25 | } 26 | } 27 | --------------------------------------------------------------------------------