Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/arifulhb/laravel-docker-app
A complete Laravel, PHP Docker based development environment with individual Nginx, Web app, Queue, Scheduler, Redis containers.
https://github.com/arifulhb/laravel-docker-app
containerization development-environment docker docker-compose laravel laravel-framework php
Last synced: 2 months ago
JSON representation
A complete Laravel, PHP Docker based development environment with individual Nginx, Web app, Queue, Scheduler, Redis containers.
- Host: GitHub
- URL: https://github.com/arifulhb/laravel-docker-app
- Owner: arifulhb
- Created: 2020-11-18T15:04:40.000Z (about 4 years ago)
- Default Branch: main
- Last Pushed: 2022-02-17T20:10:50.000Z (almost 3 years ago)
- Last Synced: 2023-04-10T02:21:08.096Z (almost 2 years ago)
- Topics: containerization, development-environment, docker, docker-compose, laravel, laravel-framework, php
- Language: Shell
- Homepage: https://dev.to/arifulhb/a-complete-docker-based-development-environment-for-laravel-php-10o4
- Size: 40 KB
- Stars: 41
- Watchers: 2
- Forks: 17
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Laravel-Docker-App
## Laravel, PHP7.3, Nginx, MySQL 5.7, Redis Docker Container
A complete Laravel, PHP Development environment that is very similar to production environment.Docker Compose based **Laravel development environment** with individual **App** _(Laravel app)_, **Nginx**, **Database** _(MySQL)_, **Queue**, **Scheduler**, **Redis** services.
## Installation
### Install Laravel
Clone the repo at your development machine. Go to your *Laravel Docker* directory. Then Run this
```
sh install
```
A bash script will download latest Laravel zip and then unzip the Laravel project into the `app` directory.### Update Laravel Version
To update Laravel version before installaiton, edit the `install` file in root directory.## Docker Container management
### Build containers
Run this to build your docker containers for each services (*app, database, queue, scheduler, redis*).
```
docker-compose build
```### Run the containers
```
docker-compose up
```
### To run the services at background
```
docker-compose up -d
```
### SSH into your app console
To **install Laravel**, _generate app key_ and _run migrations_, you need to ssh to your app container service. To ssh to your app container, run this.
```
docker-compose exec app sh
```
This will take you to `/var/www/app` path inside your `app` service container. Now you can run your `composer install` and other Laravel or PHP specific commands there.To ssh into other containers, replace the `app` with other container name as `scheduler`, `queue`. e.g.
```
docker-compose exec queue sh
```### Stop running containers
```
docker-compose stop
```## Environment Variables
### PHP
If you want to change, enable/disable any PHP settings, you can change them in `./docker/config/php/php-ini-development.ini` file and then `build` and `up` the container again.
### MySQL
MySQL username, password can be changed from `docker-compose.yml` file. Fin the `environment` section under `mysql`. Change the value and build the mysql image again with `docker-compose build mysql`.
```
environment:
MYSQL_DATABASE: app
MYSQL_ROOT_PASSWORD: root
MYSQL_USER: admin
MYSQL_PASSWORD: secret
```
After you change the value and build, you need to restart the mysql service `docker-compose up mysql` to make it affective.
### Nginx
If you want to change Nginx web host configurations, you can find the file at `./docker/images/web/sites/default.dev.conf`
### Storage and Logs
This Laravel-docker-app leverage the power of `docker volume` and store some the docker container data at your host machine. Here is the details of folder structure and what data it contain:
- `./docker/data/mysql` contain mysql database files
- `./docker/data/redis` contain redis database file
- `./docker/data/web` contain nginx webserver logs
### Connecting MySQL with local desktop client.
```
host: 0.0.0.0
username: root
password: root
port: 33066
```
## Why of Laravel-docker-app
At the moment, there are many other Laravel Docker github repo or packages available, so why this new package again? Here I'll list few of my points:
1. This docker app images is based on `alpine` based PHP image, which makes it very light weight.
2. This is built on service based architecture. Usually for Laravel application, there should be `Queue` and `cron` running on behind. In this system, you can run `Queue`, `Scheduler` container separately and Queue will listen to a separate `Redis` database.
3. It's the most compatible with production environment. Very easily this can be converted to a production grade, scalable service.## Browse your site locally
You can find your site running at http://localhost## TODO
Future development plan:
- [ ] Docker Swarm for testing and production environment
- [ ] Kubernetes scripts for testing and production environment## Contribution
If you find any security hole or improvement opportunity, feel free to fork and PR your updates. I'll be happy to merge any reasonable PR.### Contact
Email: `[email protected]`### Disclaimer
This docker environment is for development only and NOT optimized for production.