Add configurations and documentation for Laravel Sail

This commit is contained in:
Christopher C. Wells 2021-04-05 16:21:10 -07:00
parent 3fa73c8153
commit 8300105fe2
5 changed files with 190 additions and 88 deletions

View File

@ -1,19 +0,0 @@
APP_NAME=kcal
APP_ENV=local
APP_KEY=
APP_DEBUG=true
APP_URL=http://localhost
LOG_CHANNEL=stack
LOG_LEVEL=debug
DB_CONNECTION=sqlite
BROADCAST_DRIVER=log
CACHE_DRIVER=file
QUEUE_CONNECTION=sync
SESSION_DRIVER=file
SESSION_LIFETIME=120
SCOUT_DRIVER=elastic
ELASTIC_HOST=localhost:9200

35
.env.local.example Normal file
View File

@ -0,0 +1,35 @@
APP_NAME=kcal
APP_ENV=local
APP_KEY=
APP_DEBUG=true
APP_URL=http://127.0.0.1
APP_PORT=8080
APP_SERVICE=kcal.test
APP_TIMEZONE=UTC
LOG_CHANNEL=stack
LOG_LEVEL=debug
DB_CONNECTION=mysql
DB_HOST=mysql
DB_PORT=3306
DB_DATABASE=kcal
DB_USERNAME=kcal
DB_PASSWORD=kcal
REDIS_HOST=redis
REDIS_PORT=6379
SCOUT_DRIVER=elastic
ELASTIC_HOST=elasticsearch:9200
ELASTIC_PORT=9200
MAIL_HOST=mailhog
MAIL_PORT=1025
MAILHOG_ADMIN_PORT=8025
BROADCAST_DRIVER=log
CACHE_DRIVER=file
QUEUE_CONNECTION=sync
SESSION_DRIVER=file
SESSION_LIFETIME=120

31
.env.prod.example Normal file
View File

@ -0,0 +1,31 @@
APP_NAME=kcal
APP_ENV=production
APP_KEY=
APP_DEBUG=false
APP_URL=
APP_TIMEZONE=UTC
LOG_CHANNEL=stack
LOG_LEVEL=debug
DB_CONNECTION=mysql
DB_HOST=
DB_PORT=3306
DB_DATABASE=
DB_USERNAME=
DB_PASSWORD=
REDIS_HOST=
REDIS_PORT=6379
SCOUT_DRIVER=elastic
ELASTIC_HOST=
MAIL_HOST=
MAIL_PORT=
BROADCAST_DRIVER=log
CACHE_DRIVER=file
QUEUE_CONNECTION=sync
SESSION_DRIVER=file
SESSION_LIFETIME=120

View File

@ -1,3 +1,50 @@
# kcal the personal food nutrition journal
[![CI Status](https://github.com/kcal-app/kcal/actions/workflows/ci.yml/badge.svg)](https://github.com/kcal-app/kcal/actions/workflows/ci.yml)
[![Coverage \status](https://coveralls.io/repos/github/kcal-app/kcal/badge.svg)](https://coveralls.io/github/kcal-app/kcal?branch=tests)
## Development
### Laravel Sail
#### Prerequisites
- [Composer](https://getcomposer.org/download/)
- [Docker](https://docs.docker.com/get-docker/)
- [Docker compose](https://docs.docker.com/compose/install/)
1. Clone the repository.
git clone https://github.com/kcal-app/kcal.git
1. Move in to the cloned folder.
cd kcal
1. Install development dependencies.
composer install
1. Create a local `.env` file.
cp .env.local.example .env
Note: the default `APP_URL` setting is `http://127.0.0.1`. If you have
[dnsmasq](https://thekelleys.org.uk/dnsmasq/doc.html) or something similar
configured for the `test` domain you can change this to `http://kcal.test`.
1. Generate an app key.
touch .env
php artisan key:generate
1. Run it! :sailboat:
vendor/bin/sail up -d
1. (On first run) Run migrations.
vendor/bin/sail artisan migrate
vendor/bin/sail artisan elastic:migrate
Once the application finishing starting, navigate to [http://127.0.0.1:8080](http://127.0.0.1:8080)
(or [http://kcal.test:8080](http://kcal.test:8080) if configured).

View File

@ -1,7 +1,7 @@
# For more information: https://laravel.com/docs/sail
version: '3'
services:
laravel.test:
kcal.test:
build:
context: ./vendor/laravel/sail/runtimes/8.0
dockerfile: Dockerfile
@ -9,7 +9,7 @@ services:
WWWGROUP: '${WWWGROUP}'
image: sail-8.0/app
ports:
- '${APP_PORT:-80}:80'
- '${APP_PORT:-8080}:80'
environment:
WWWUSER: '${WWWUSER}'
LARAVEL_SAIL: 1
@ -20,55 +20,63 @@ services:
depends_on:
- mysql
- redis
# - selenium
# selenium:
# image: 'selenium/standalone-chrome'
# volumes:
# - '/dev/shm:/dev/shm'
# networks:
# - sail
# depends_on:
# - laravel.test
- elasticsearch
mysql:
image: 'mysql:8.0'
ports:
- '${FORWARD_DB_PORT:-3306}:3306'
- '${DB_PORT:-3306}:3306'
environment:
MYSQL_ROOT_PASSWORD: '${DB_PASSWORD}'
MYSQL_DATABASE: '${DB_DATABASE}'
MYSQL_USER: '${DB_USERNAME}'
MYSQL_PASSWORD: '${DB_PASSWORD}'
MYSQL_ROOT_PASSWORD: '${DB_PASSWORD:-kcal}'
MYSQL_DATABASE: '${DB_DATABASE:-kcal}'
MYSQL_USER: '${DB_USERNAME:-kcal}'
MYSQL_PASSWORD: '${DB_PASSWORD:-kcal}'
MYSQL_ALLOW_EMPTY_PASSWORD: 'yes'
volumes:
- 'sailmysql:/var/lib/mysql'
- 'mysql-data:/var/lib/mysql'
networks:
- sail
elasticsearch:
image: 'elasticsearch:7.12.0'
environment:
- xpack.security.enabled=false
- discovery.type=single-node
ulimits:
memlock:
soft: -1
hard: -1
nofile:
soft: 65536
hard: 65536
cap_add:
- IPC_LOCK
volumes:
- elasticsearch-data:/usr/share/elasticsearch/data
ports:
- '${ELASTIC_PORT:-9200}:9200'
networks:
- sail
redis:
image: 'redis:alpine'
ports:
- '${FORWARD_REDIS_PORT:-6379}:6379'
- '${REDIS_PORT:-6379}:6379'
volumes:
- 'sailredis:/data'
- 'redis-data:/data'
networks:
- sail
# memcached:
# image: 'memcached:alpine'
# ports:
# - '11211:11211'
# networks:
# - sail
mailhog:
image: 'mailhog/mailhog:latest'
ports:
- 1025:1025
- 8025:8025
- '${MAIL_PORT:-1025}:1025'
- '${MAILHOG_ADMIN_PORT:-8025}:8025'
networks:
- sail
networks:
sail:
driver: bridge
volumes:
sailmysql:
elasticsearch-data:
driver: local
sailredis:
mysql-data:
driver: local
redis-data:
driver: local