laradock/README.md

263 lines
6.8 KiB
Markdown
Raw Normal View History

2015-08-22 03:53:44 +08:00
# LaraDock
[![forthebadge](http://forthebadge.com/images/badges/built-with-love.svg)](http://www.zalt.me)
### What is this?
2015-08-22 18:03:20 +08:00
**LaraDock** is a starter project to get you up and running with **Laravel** 5 and **Docker**.
It includes a Laravel `v5.1.10` fresh installation and a pre-configured **Docker Compose** file (containg most required **images** to run a Laravel application).
2015-08-22 03:53:44 +08:00
![](http://s11.postimg.org/uqpl3efab/laradock.jpg)
### What is Docker?
[Docker](https://www.docker.com) is an open-source project that automates the deployment of applications inside software containers, by providing an additional layer of abstraction and automation of [operating-system-level virtualization](https://en.wikipedia.org/wiki/Operating-system-level_virtualization) on Linux, Mac OS and Windows.
2015-08-22 03:53:44 +08:00
### What is Laravel?
Are you serious!!
### Why Docker not Vagrant?!
2015-08-22 04:17:24 +08:00
[Vagrant](https://www.vagrantup.com) gives you Virtual Machines in minutes while Docker gives you Linux Containers in seconds.
2015-08-22 03:53:44 +08:00
Instead of providing a full Virtual Machines, like you get with Vagrant, Docker provides you **lightweight** Virtual Containers, that share the same kernel and allow to safely execute independent processes.
### What's next?
LaraDock strives to make the development experience easier.
And it is inspired by [Laravel Homestead](http://laravel.com/docs/master/homestead).
*In the near future LaraDock will become a stand-alone package that manages your Docker Virtual Containers as Homestead does with your Vagrant Virtual Machines.*
### Questions?
If you have any questions please share it with us on [![Join the chat at https://gitter.im/LaraDock/laradock](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/LaraDock/laradock?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) or email me on (mahmoud@zalt.me).
2015-08-22 03:53:44 +08:00
<a name="Highlights"></a>
## Highlights
__Included Images:__
- NGINX+PHP
- MySQL
- Redis
- Beanstalked
- Data Volume (for MySQL & Redis)
Note: PHP and NGINX are in one container, I will split them whenever I see the need for it.
2015-08-22 18:03:20 +08:00
## Contents
- [Requirements](#Requirements)
- [Usage](#Usage)
- [Documentation](#Documentation)
2015-08-22 03:53:44 +08:00
<a name="Requirements"></a>
## Requirements
- Docker toolbox ([Download](https://www.docker.com/toolbox)) this includes:
2015-08-22 04:17:24 +08:00
- VirtualBox
2015-08-22 03:53:44 +08:00
- Docker Client
- Docker Machine
- Docker Compose (Required)
- Docker Kitematic (Not Important)
- Git ([Download](https://git-scm.com/downloads))
- Composer ([Download](https://getcomposer.org/download/))
*Note: Git & Composer can be installed on Docker Containers if you don't want to install them on your machine. (But you have to do this yourself for now).*
<a name="Usage"></a>
## Usage
2015-08-22 18:03:20 +08:00
1 - First clone the project
2015-08-22 03:53:44 +08:00
```bash
git clone https://github.com/LaraDock/laradock laradock
2015-08-22 03:53:44 +08:00
```
2 - Inside `laradock` there are 2 directories (Laravel and Docker) let's start with Laravel
```bash
cd laradock/laravel
```
3 - Install the Composer packages
```bash
composer install
```
2015-08-22 18:03:20 +08:00
4 - On laravel's root directory `laradock/laravel`, rename the file `.env.docker` to `.env`
2015-08-23 19:20:24 +08:00
```bash
sudo mv .env.docker .env
```
2015-08-22 18:03:20 +08:00
5 - Provide some permissions (directories should be writable by the web server)
2015-08-22 03:53:44 +08:00
```bash
2015-08-22 18:03:20 +08:00
sudo chmod -R 777 storage && sudo chmod -R 777 bootstrap/cache
2015-08-22 03:53:44 +08:00
```
2015-08-22 18:03:20 +08:00
6 - Now let's start with the Docker stuff
2015-08-22 03:53:44 +08:00
```bash
cd ../docker
```
2015-08-23 19:20:24 +08:00
7 - Edit the hosts file `/etc/hosts` on your machine, to map your `Docker IP` to the `laravel.dev` domain
2015-08-22 03:53:44 +08:00
```bash
2015-08-23 19:20:24 +08:00
sudo nano /etc/hosts
2015-08-22 03:53:44 +08:00
```
2015-08-23 19:20:24 +08:00
`127.0.0.x laravel.dev`
> To find the IP address:
>
> - if you are on Linux, the containers run directly on your localhost so this `127.0.0.1` will be your IP Address.
> - if you are on MAC using **boot2docker**, run this command while boot2docker is up `boot2docker ip` to get the IP Address.
> - if you are on Windows, check the Docker documentation for how you get the VM IP Address.
2015-08-22 18:03:20 +08:00
8 - Finally run the containers and start coding.
2015-08-22 03:53:44 +08:00
2015-08-22 04:17:24 +08:00
*"Note: Only the first you run this command will take up to 7 minutes (depend on your connection speed) to download the images to your local machine, Only once in life.*
2015-08-22 03:53:44 +08:00
```bash
docker-compose up -d
```
2015-08-22 18:03:20 +08:00
9 - Open your browser and visit `http://laravel.dev`
2015-08-22 03:53:44 +08:00
2015-08-22 04:17:24 +08:00
You should see a page like this:
2015-08-22 03:53:44 +08:00
![](http://s29.postimg.org/8cvh7wq2f/Screen_Shot_2015_08_21_at_9_23_19_PM.png)
2015-08-22 18:03:20 +08:00
2015-08-22 03:53:44 +08:00
<a name="Documentation"></a>
## Documentation
2015-08-23 19:20:24 +08:00
#### See current running Containers
```bash
docker ps
```
2015-08-22 03:53:44 +08:00
#### Close all running Containers
```bash
docker-compose stop
```
#### Delete all existing Containers
```bash
docker-compose rm -f
```
2015-08-22 04:17:24 +08:00
*Note: Careful with this command as it will delete your Data Volume Container as well. (if you want to keep your Database data than you should stop each container by itself as follow):*
`docker stop {container-name}`
2015-08-22 03:53:44 +08:00
#### Delete an Image (remove the unused software)
2015-08-22 04:17:24 +08:00
To delete an image (software), just edit the `laradock/docker/docker-compose.yml` file.
2015-08-22 03:53:44 +08:00
**Example:** Assume you want to remove the `Beanstalkd` Container.
2015-08-22 03:53:44 +08:00
Open the `docker-compose.yml` file, and comment out the `beanstalkd` section:
2015-08-22 18:03:20 +08:00
```yml
2015-08-22 03:53:44 +08:00
# Beanstalkd Container #-----------------------------------
# beanstalkd:
# image: laradock/beanstalkd:latest
# container_name: beanstalkd
# ports:
# - "11300:11300"
# privileged: true
```
#### Add an Image (add a software to run with other Containers)
2015-08-22 04:17:24 +08:00
To add an image (software), just edit the `laradock/docker/docker-compose.yml` and add your container details, to do so you need to be familiar with the [docker compose file syntax](https://docs.docker.com/compose/yml/).
2015-08-22 03:53:44 +08:00
2015-08-22 18:03:20 +08:00
#### Edit a Container (change Ports or Volumes)
To modify a container you can simply open the `laradock/docker/docker-compose.yml` and change everything you want.
Example: if you want to set the MySQL port to 3333, just replace the default port with yours:
```yml
ports:
- "3333:3306"
```
2015-08-22 03:53:44 +08:00
#### Edit an existing Image (change some configuration in the image)
To edit an image, and take full control of it:
1. clone the LaraDock `docker-images` repository [https://github.com/LaraDock/docker-images](https://github.com/LaraDock/images)
2015-08-22 03:53:44 +08:00
2. modify whichever `Dockfile` you want
3. from the modified image directory run `docker build -t {your-image-name} .`
All the images are open source and hosted on the [Docker Hub](https://hub.docker.com/u/laradock/).
2015-08-22 04:17:24 +08:00
*If you find any bug or you have and suggestion that can improve the performance of any image, please consider contributing. Thanks in advance.*
2015-08-22 03:53:44 +08:00
2015-08-22 18:03:20 +08:00
#### View the Log files
The Log files are stored in the `laradock/docker/logs` directory.
2015-08-22 03:53:44 +08:00
## Contributing
2015-08-22 04:17:24 +08:00
All contributions are welcomed.
2015-08-22 03:53:44 +08:00
## Support
[Issues](https://github.com/laradock/laradock/issues) on Github.
2015-08-22 03:53:44 +08:00
## Credits
[![Mahmoud Zalt](https://img.shields.io/badge/Author-Mahmoud%20Zalt-orange.svg)](http://www.zalt.me)
## License
[MIT License (MIT)](https://github.com/laradock/laradock/blob/master/LICENSE)
2015-08-22 03:53:44 +08:00