Skip to content

Instantly share code, notes, and snippets.

@ohmydevops
Last active April 29, 2021 10:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ohmydevops/8599e0a92996aa28b19fd96b22a58d10 to your computer and use it in GitHub Desktop.
Save ohmydevops/8599e0a92996aa28b19fd96b22a58d10 to your computer and use it in GitHub Desktop.
Laravel 8 sail configurations for my projects (PHP7.4 + MySQL8.0 + Redis5.0 + PHPMyAdmin5)
# For more information: https://laravel.com/docs/sail
version: '3'
services:
laravel.test:
container_name: sail-laravel
build:
context: ./vendor/laravel/sail/runtimes/7.4
dockerfile: Dockerfile
args:
WWWGROUP: '${WWWGROUP}'
image: sail-7.4/app
ports:
- '${APP_PORT:-80}:80'
environment:
WWWUSER: '${WWWUSER}'
LARAVEL_SAIL: 1
volumes:
- '.:/var/www/html'
networks:
- sail
depends_on:
- mysql
- redis
redis:
image: 'redis:5'
container_name: sail-redis
command: redis-server --requirepass ${REDIS_PASSWORD:-123456789}
ports:
- '${FORWARD_REDIS_PORT:-6379}:6379'
volumes:
- 'sailredis:/data'
networks:
- sail
healthcheck:
test: ["CMD", "redis-cli", "ping"]
mysql:
image: 'mysql:8.0'
container_name: sail-mysql
ports:
- '${FORWARD_DB_PORT:-3306}:3306'
environment:
MYSQL_ROOT_PASSWORD: '${DB_PASSWORD}'
MYSQL_DATABASE: '${DB_DATABASE}'
MYSQL_USER: '${DB_USERNAME}'
MYSQL_PASSWORD: '${DB_PASSWORD}'
volumes:
- 'sailmysql:/var/lib/mysql'
networks:
- sail
healthcheck:
test: ["CMD", "mysqladmin", "ping"]
restart: always
phpmyadmin:
image: phpmyadmin:5.0.4
container_name: sail-phpmyadmin
networks:
- sail
environment:
PMA_HOST: mysql
PMA_PORT: 3306
UPLOAD_LIMIT: 1G
depends_on:
- mysql
restart: always
ports:
- '${PHPMYADMIN_PORT:-9090}:80'
networks:
sail:
driver: bridge
volumes:
sailmysql:
driver: local
sailredis:
driver: local
@ohmydevops
Copy link
Author

ohmydevops commented Mar 7, 2021

Installation / Running:

cd YOUR_PROJECT_DIR
composer require laravel/sail --dev
docker volume create sailmysql
docker volume create sailredis

(copy the above docker-compose.yml in your project, then fill your `.env` file)

./vendor/bin/sail
./vendor/bin/sail up
./vendor/bin/sail down
./vendor/bin/sail php --version
./vendor/bin/sail node --version
./vendor/bin/sail php artisan --help
./vendor/bin/sail shell
./vendor/bin/sail tinker

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment