diff --git a/Makefile b/Makefile index 153acff6..9da02144 100644 --- a/Makefile +++ b/Makefile @@ -16,13 +16,10 @@ create-project: docker compose exec app php artisan storage:link docker compose exec app chmod -R 777 storage bootstrap/cache @make fresh -up: - docker compose up -d build: docker compose build -remake: - @make destroy - @make install +up: + docker compose up -d stop: docker compose stop down: @@ -34,28 +31,19 @@ restart: @make up destroy: docker compose down --rmi all --volumes --remove-orphans +remake: + @make destroy + @make install ps: docker compose ps -logs: - docker compose logs -logs-watch: - docker compose logs --follow -log-web: - docker compose logs web -log-web-watch: - docker compose logs --follow web -log-app: - docker compose logs app -log-app-watch: - docker compose logs --follow app -log-db: - docker compose logs db -log-db-watch: - docker compose logs --follow db web: docker compose exec web bash app: docker compose exec app bash +tinker: + docker compose exec app php artisan tinker +test: + docker compose exec app php artisan test migrate: docker compose exec app php artisan migrate fresh: @@ -67,10 +55,6 @@ dacapo: rollback-test: docker compose exec app php artisan migrate:fresh docker compose exec app php artisan migrate:refresh -tinker: - docker compose exec app php artisan tinker -test: - docker compose exec app php artisan test optimize: docker compose exec app php artisan optimize optimize-clear: @@ -84,6 +68,7 @@ cache-clear: docker compose exec app composer clear-cache @make optimize-clear docker compose exec app php artisan event:clear + docker compose exec app php artisan view:clear db: docker compose exec db bash sql: diff --git a/README.md b/README.md index 5163c231..5d6a12ff 100644 --- a/README.md +++ b/README.md @@ -22,6 +22,10 @@ Build a simple laravel development environment with docker-compose. Compatible w 3. Execute the following command ```bash +$ task create-project + +# or... + $ make create-project # or... @@ -44,13 +48,29 @@ http://localhost 2. Execute the following command ```bash +# https://taskfile.dev +$ task install + +# or... + $ make install + +# or... + +$ docker compose build +$ docker compose up -d +$ docker compose exec app composer install +$ docker compose exec app cp .env.example .env +$ docker compose exec app php artisan key:generate +$ docker compose exec app php artisan storage:link +$ docker compose exec app chmod -R 777 storage bootstrap/cache ``` http://localhost ## Tips +- Read this [Taskfile](https://github.com/ucan-lab/docker-laravel/blob/main/Taskfile.yml). - Read this [Makefile](https://github.com/ucan-lab/docker-laravel/blob/main/Makefile). - Read this [Wiki](https://github.com/ucan-lab/docker-laravel/wiki). diff --git a/Taskfile.yml b/Taskfile.yml new file mode 100644 index 00000000..395712a6 --- /dev/null +++ b/Taskfile.yml @@ -0,0 +1,144 @@ +version: '3' + +tasks: + install: + cmds: + - docker compose build + - docker compose up -d + - docker compose exec app composer install + - docker compose exec app cp .env.example .env + - docker compose exec app php artisan key:generate + - docker compose exec app php artisan storage:link + - docker compose exec app chmod -R 777 storage bootstrap/cache + + create-project: + cmds: + - mkdir -p src + - docker compose build + - docker compose up -d + - docker compose exec app composer create-project --prefer-dist laravel/laravel . + - docker compose exec app php artisan key:generate + - docker compose exec app php artisan storage:link + - docker compose exec app chmod -R 777 storage bootstrap/cache + + build: + cmds: + - docker compose build + + up: + cmds: + - docker compose up -d + + down: + cmds: + - docker compose down --remove-orphans + + down-v: + cmds: + - docker compose down --remove-orphans --volumes + + stop: + cmds: + - docker compose stop + + restart: + cmds: + - docker compose down --remove-orphans + - docker compose up -d + + destroy: + cmds: + - docker compose down --rmi all --volumes --remove-orphans + + remake: + cmds: + - docker compose down --rmi all --volumes --remove-orphans + - docker compose build + - docker compose up -d + - docker compose exec app composer install + - docker compose exec app cp .env.example .env + - docker compose exec app php artisan key:generate + - docker compose exec app php artisan storage:link + - docker compose exec app chmod -R 777 storage bootstrap/cache + + ps: + cmds: + - docker compose ps + + web: + cmds: + - docker compose exec web bash + + app: + cmds: + - docker compose exec web bash + + tinker: + cmds: + - docker compose exec app php artisan tinker + + test: + cmds: + - docker compose exec app php artisan test + + migrate: + cmds: + - docker compose exec app php artisan migrate + + fresh: + cmds: + - docker compose exec app php artisan migrate:fresh --seed + + seed: + cmds: + - docker compose exec app php artisan db:seed + + dacapo: + cmds: + - docker compose exec app php artisan dacapo + + rollback-test: + cmds: + - docker compose exec app php artisan migrate:fresh + - docker compose exec app php artisan migrate:refresh + + optimize: + cmds: + - docker compose exec app php artisan optimize + + optimize-clear: + cmds: + - docker compose exec app php artisan optimize:clear + + cache: + cmds: + - docker compose exec app composer dump-autoload -o + - docker compose exec app php artisan optimize + - docker compose exec app php artisan event:cache + - docker compose exec app php artisan view:cache + + cache-clear: + cmds: + - docker compose exec app composer clear-cache + - docker compose exec app php artisan optimize:clear + - docker compose exec app php artisan event:clear + - docker compose exec app php artisan view:clear + + db: + cmds: + - docker compose exec db bash + + sql: + cmds: + - docker compose exec db bash -c 'mysql -u $$MYSQL_USER -p$$MYSQL_PASSWORD $$MYSQL_DATABASE' + + redis: + cmds: + - docker compose exec redis redis-cli + + ide-helper: + cmds: + - docker compose exec app php artisan clear-compiled + - docker compose exec app php artisan ide-helper:generate + - docker compose exec app php artisan ide-helper:meta + - docker compose exec app php artisan ide-helper:models --nowrite