Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ityetti/laravel-docker
Laravel Docker to Development (Apple Silicon): Traefik + Nginx + Redis + PHP-FPM + MySQL + xDebug + Mailpit + RabbitMQ + OpenSearch + Varnish
https://github.com/ityetti/laravel-docker
apple-silicon-support applesilicon docker laravel mailpit mysql nginx opensearch opensearch-dashboards php redis traefik varnish
Last synced: 5 days ago
JSON representation
Laravel Docker to Development (Apple Silicon): Traefik + Nginx + Redis + PHP-FPM + MySQL + xDebug + Mailpit + RabbitMQ + OpenSearch + Varnish
- Host: GitHub
- URL: https://github.com/ityetti/laravel-docker
- Owner: ityetti
- License: mit
- Created: 2024-12-03T21:11:18.000Z (19 days ago)
- Default Branch: main
- Last Pushed: 2024-12-10T21:28:21.000Z (12 days ago)
- Last Synced: 2024-12-10T22:26:21.848Z (12 days ago)
- Topics: apple-silicon-support, applesilicon, docker, laravel, mailpit, mysql, nginx, opensearch, opensearch-dashboards, php, redis, traefik, varnish
- Language: Dockerfile
- Homepage: https://github.com/ityetti/laravel-docker
- Size: 18.6 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
- Security: SECURITY.md
Awesome Lists containing this project
README
# Laravel 2 Docker to Development (Apple Silicon)
### Traefik + Nginx + Redis + PHP-FPM + MySQL + XDebug + Mailpit + RabbitMQ + OpenSearch + Varnish
The docker stack is composed of the following containers
| Name | Version |
|----------------------|---------|
| traefik | 3.2 |
| nginx | 1.27 |
| php-fpm | 8.2 |
| php-fpm-xdebug | 3.2.2 |
| redis | 7.4 |
| mysql | 8.4.3 |
| mailpit | 1.21 |
| rabbitmq | 4.0.4 |
| opensearch | 2.18 |
| opensearch-dashboard | 2.18 |
| varnish | 7.6 |### Container traefik
Starts a reverse proxy and load balancer for project
Opens local port: `80`, `443`### Container nginx
Builds from the nginx folder.
Mounts the folder laravel from the project main folder into the container volume `/home/laravel`.### Container php-fpm
Builds from the php-fpm folder.
Mounts the folder laravel from the project main folder into the container volume `/home/laravel`.
This container includes all dependencies for Laravel.### Container php-fpm-xdebug
Builds from the php-fpm-xdebug folder.
Mounts the folder laravel from the project main folder into the container volume `/home/laravel`.
This container includes all dependencies for Laravel (also contain xDebug).### Container redis:
Starts a redis container.### Container mysql:
Please change or set the mysql environment variables
MYSQL_DATABASE: 'xxxx'
MYSQL_ROOT_PASSWORD: 'xxxx'
MYSQL_USER: 'xxxx'
MYSQL_PASSWORD: 'xxxx'
MYSQL_ALLOW_EMPTY_PASSWORD: 'xxxxx'Default values:
MYSQL_DATABASE: 'laravel'
MYSQL_ROOT_PASSWORD: 'root_pass'
MYSQL_USER: 'laravel_user'
MYSQL_PASSWORD: 'PASSWD#'
MYSQL_ALLOW_EMPTY_PASSWORD: 'false'Opens up port: `3306`
Note: On your host, port 3306 might already be in use. So before running docker-compose.yml, under the docker-compose.yml's mysql section change the host's port number to something other than 3306, select any as long as that port is not already being used locally on your machine.
### Container mailpit:
Starts a mailpit container.
Opens up port: `8025`### Container rabbitmq:
Starts a rabbitmq container.
Opens up port: `15672`### Container opensearch:
Starts an opensearch container.### Container opensearch-dashboard:
Starts an opensearch dashboard container.
Opens up port: `5601`### Container varnish:
Builds from the varnish folder.
Starts a varnish container.
Opens up port: `6081`## Setup
Copy your `.env.sample` to `.env` file in root folder, and change `PROJECT_NAME` and `PROJECT_VIRTUAL_HOST`:
`PROJECT_NAME` - help you to create simple and clear container names.
`PROJECT_VIRTUAL_HOST` - it is your main url address.For example:
PROJECT_NAME=laravel
PROJECT_VIRTUAL_HOST=laravel.testEdit your `/etc/hosts` and add next line:
`127.0.0.1 laravel.test traefik.laravel.test mail.laravel.test search.laravel.test dashboard.laravel.test rabbit.laravel.test`To start/build the stack.
Use - `docker-compose up` or `docker-compose up -d` to run the container on detached mode.
Compose will take some time to execute.
After the build has finished you can press the ctrl+c and docker-compose stop all containers.## Installing Laravel
To the run installation process use next commands.
Create and install new project:./scripts/composer create-project laravel/laravel .
./scripts/npm install
./scripts/npm run build
./scripts/php artisan key:generate
./scripts/php artisan migrate## Setting up Laravel
To access the laravel homepage, go to the following url: https://laravel.testStoring sessions and cache in redis.
##### As reference, you could use files from `laravel_config` folder.
#### Setting up vite.config.js (you need to add the correct server configuration).
```js
server: {
host: 'nginx',
port: 5175,
https: true,
},
```#### Setting up the boot method in /app/Providers/AppServiceProvider.php (it is necessary for the correct use of HTTPS locally).
```php
public function boot(): void
{
if (config('app.env') === 'local') {
URL::forceScheme('https');
}
}
```#### Don't forget to change the following parameters in the .env file of the Laravel app folder.
```php
APP_URL=https://laravel.test
DB_CONNECTION=mysql
DB_HOST=mysql
DB_PORT=3306
DB_DATABASE=laravel_db
DB_USERNAME=laravel_user
DB_PASSWORD="PASSWD#"
REDIS_CLIENT=redis
REDIS_HOST=redis
REDIS_PASSWORD=null
REDIS_PORT=6379
MAIL_HOST=mailpit
```## How to use xDebug
You could enable or disable xDebug with the next command: `./scripts/switch_mode [fpm|xdebug]`
`fpm` - Enable container without xDebug
`xdebug` - Enable container with xDebugAlso, you can open:
https://traefik.laravel.test - **Traefik Dashboard** (traefik/traefik123 for access)
https://mail.laravel.test - **Mailpit**
https://search.laravel.test - **OpenSearch**
https://dashboard.laravel.test - **OpenSearch Dashboard**
https://rabbit.laravel.test - **RabbitMQ** (guest/guest for access)## Feature Updates
- v1.0.0 - Initial release## Branches
| Name | Laravel |
|------|---------|
| main | 11.x |