diff --git a/.editorconfig b/.editorconfig index 42a78b8..448abd8 100644 --- a/.editorconfig +++ b/.editorconfig @@ -19,3 +19,6 @@ indent_size = 2 [Makefile] indent_style = tab + +[justfile] +indent_size = 2 diff --git a/.env.example b/.env.example index 03b3616..7ec0c95 100644 --- a/.env.example +++ b/.env.example @@ -1,10 +1,13 @@ +# Database +# config/database.php DB_CONNECTION=mysql DB_HOST=mysql DB_PORT=3306 DB_DATABASE=app DB_USERNAME=laravel DB_PASSWORD=secret -DB_ROOT_PASSWORD=secret +# Docker +DB_ROOT_PASSWORD=secret APP_UID=1000 APP_GID=1000 diff --git a/.gitignore b/.gitignore index 877d5c9..6b892d1 100644 --- a/.gitignore +++ b/.gitignore @@ -9,7 +9,7 @@ Homestead.json # Vendor / dependencies /vendor /composer/ -.composer-hash +.composer/ # Laravel storage and cache /storage/*.key @@ -23,6 +23,7 @@ Homestead.json # Build artifacts /public/build /public/hot +/public/docs /bootstrap/cache/* !/bootstrap/cache/.gitignore @@ -35,40 +36,12 @@ Homestead.json /.vscode .phpactor.json .scribe/ -.scribe-hash # System / logs *.log .DS_Store Thumbs.db .bash_history -/bootstrap/ssr -/node_modules -/public/build -/public/hot -/public/storage -/storage/*.key -/storage/pail -/resources/js/actions -/resources/js/routes -/resources/js/wayfinder -/vendor -.DS_Store -.env -.env.backup -.env.production -.phpactor.json -.phpunit.result.cache -Homestead.json -Homestead.yaml -npm-debug.log -yarn-error.log -/auth.json -/.fleet -/.idea -/.nova -/.vscode -/.zed -.composer-hash -.scribe-hash +# Custom +.hashes/ diff --git a/Makefile b/Makefile deleted file mode 100644 index c7d1ffd..0000000 --- a/Makefile +++ /dev/null @@ -1,61 +0,0 @@ --include .env -APP_UID ?= 1000 -APP_GID ?= 1000 - -IMAGE_NAME := laravel-setup-php-fpm -IMAGE_TAG := latest -IMAGE := $(IMAGE_NAME):$(IMAGE_TAG) -TAR_FILE := $(IMAGE_NAME)_$(IMAGE_TAG).tar.gz - -.PHONY: help build load shell docs db - -help: - @echo "Usage:" - @echo " make [SOURCE=...]" - @echo "" - @echo "Targets:" - @echo " build Build Docker image and save to archive" - @echo " load Load Docker image from archive, URL, or build if missing" - @echo " Optional: SOURCE=url_or_file" - @echo " shell Enter php-fpm container as www" - @echo " docs Regenerate API documentation" - @echo " db Recreate DB" - - -build: - @echo "Building image..." - docker build -f docker/Dockerfile --build-arg UID=$(APP_UID) --build-arg GID=$(APP_GID) -t $(IMAGE) . - @echo "Saving image to $(TAR_FILE)..." - docker save $(IMAGE) | gzip > $(TAR_FILE) - -load: -ifdef SOURCE - @if echo "$(SOURCE)" | grep -qE '^https?://'; then \ - echo "Downloading and loading image from $(SOURCE)..."; \ - curl -L "$(SOURCE)" -o $(TAR_FILE); \ - docker load < $(TAR_FILE); \ - else \ - echo "Loading image from file $(SOURCE)..."; \ - docker load < $(SOURCE); \ - fi -else - @if [ -f "$(TAR_FILE)" ]; then \ - echo "Loading image from archive $(TAR_FILE)..."; \ - docker load < $(TAR_FILE); \ - else \ - echo "No archive found; building image..."; \ - docker build -f docker/Dockerfile --build-arg UID=$(APP_UID) --build-arg GID=$(APP_GID) -t $(IMAGE) .; \ - fi -endif - -shell: - @echo "Entering php-fpm container as www..." - docker compose exec --user www php-fpm bash - -docs: - @echo "Regenerating API documentation..." - docker compose exec --user www php-fpm php artisan scribe:generate - -db: - @echo "Recreate DB..." - docker compose exec --user www php-fpm bash -c "php artisan migrate:fresh --seed" diff --git a/README.md b/README.md index 45b6655..55d2e55 100644 --- a/README.md +++ b/README.md @@ -2,16 +2,18 @@ - PHP-FPM, NGINX, MySQL, phpMyAdmin (in `compose.yaml`) -## Create a project: +## Run a container ```bash cp .env.example .env # !change .env for yourself docker compose up -d php-fpm -docker compose exec php-fpm bash -# or `make shell` +docker compose exec --user www php-fpm bash +# or `just shell` ``` +## Create a project: + **_Rewrite below for yourself:_** *RECOMENDED:* @@ -25,6 +27,7 @@ export PATH="$HOME/.composer/vendor/bin:$PATH" # Check options via `laravel new -h` laravel new example-app +# copy your `.env` content to `example-app/.env` mv example-app/* example-app/.* ./ rmdir example-app ``` @@ -36,6 +39,7 @@ rmdir example-app ```bash composer create-project --prefer-dist laravel/laravel example-app ^11.0 +# copy your `.env` content to `example-app/.env` mv example-app/* example-app/.* ./ rmdir example-app ``` @@ -43,5 +47,5 @@ rmdir example-app ## Quick Actions ```bash -make help +just ``` diff --git a/docker/nginx.conf b/docker/nginx.conf index 9869f38..60b42e6 100644 --- a/docker/nginx.conf +++ b/docker/nginx.conf @@ -1,5 +1,6 @@ server { listen 80; + client_max_body_size 20M; index index.php index.html; error_log /var/log/nginx/error.log; access_log /var/log/nginx/access.log; diff --git a/justfile b/justfile new file mode 100644 index 0000000..d0529d1 --- /dev/null +++ b/justfile @@ -0,0 +1,36 @@ +set dotenv-load +set shell := ["bash", "-eu", "-o", "pipefail", "-c"] + +APP_UID := env("APP_UID", "1000") +APP_GID := env("APP_GID", "1000") + +IMAGE_NAME := "laravel-setup-php-fpm" +IMAGE_TAG := "latest" +IMAGE := IMAGE_NAME + ":" + IMAGE_TAG + +# Show available recipes +default: + @just --list + +# Build Docker image +build: + docker build -f docker/Dockerfile \ + --build-arg UID={{APP_UID}} \ + --build-arg GID={{APP_GID}} \ + -t {{IMAGE}} . + +# Open shell in PHP-FPM container +shell: + docker compose exec --user www php-fpm bash + +# Generate API documentation +docs: + docker compose exec --user www php-fpm php artisan scribe:generate + +# Reset database with fresh migration and seeding +db: + docker compose exec --user www php-fpm php artisan migrate:fresh --seed + +# Run tests +test: + docker compose exec --user www php-fpm php artisan test