From 1b69c39a93a8b010a7769aa534a0b302fb2d620e Mon Sep 17 00:00:00 2001 From: HomeOS Bootstrap Date: Fri, 17 Jul 2026 21:24:10 +0200 Subject: [PATCH] Fix R15 findings: fresh-clone bootstrap + never seed a blank admin password - Document the first-run path (deps/assets/key/migrate aren't auto-installed because vendor/node_modules/public-build are gitignored): add docker/app/bootstrap.sh and a README with the exact sequence to run before `docker compose up`. - Seeder: fall back with `?:` so a present-but-empty HOMEOS_ADMIN_PASSWORD can never create a blank-password admin; .env.example ships a non-empty dev value. Co-Authored-By: Claude Opus 4.8 --- .env.example | 2 +- README.md | 76 +++++++++++++---------------- database/seeders/DatabaseSeeder.php | 6 ++- docker/app/bootstrap.sh | 28 +++++++++++ 4 files changed, 67 insertions(+), 45 deletions(-) create mode 100755 docker/app/bootstrap.sh diff --git a/.env.example b/.env.example index 96a83c1..73869d2 100644 --- a/.env.example +++ b/.env.example @@ -74,4 +74,4 @@ DB_HOST_PORT=5432 # --- HomeOS admin (dev seed; set a strong value, change for production) --- HOMEOS_ADMIN_EMAIL=admin@homeos.local HOMEOS_ADMIN_NAME=Admin -HOMEOS_ADMIN_PASSWORD= +HOMEOS_ADMIN_PASSWORD=homeos-dev diff --git a/README.md b/README.md index 5ad1377..cd88a8c 100644 --- a/README.md +++ b/README.md @@ -1,58 +1,48 @@ -

Laravel Logo

+# HomeOS -

-Build Status -Total Downloads -Latest Stable Version -License -

+Self-built smart-home control plane — single household, self-hosted, LAN-first. +Laravel 13 · Livewire v3 · Tailwind v4 · PostgreSQL 17 + TimescaleDB · Redis/Horizon · Reverb. -## About Laravel +Everything runs in Docker; the host needs **only Docker** (no PHP/Composer/Node). +Authoritative spec: [`handoff.md`](handoff.md) · conventions: [`rules.md`](rules.md) · guide: [`CLAUDE.md`](CLAUDE.md). -Laravel is a web application framework with expressive, elegant syntax. We believe development must be an enjoyable and creative experience to be truly fulfilling. Laravel takes the pain out of development by easing common tasks used in many web projects, such as: - -- [Simple, fast routing engine](https://laravel.com/docs/routing). -- [Powerful dependency injection container](https://laravel.com/docs/container). -- Multiple back-ends for [session](https://laravel.com/docs/session) and [cache](https://laravel.com/docs/cache) storage. -- Expressive, intuitive [database ORM](https://laravel.com/docs/eloquent). -- Database agnostic [schema migrations](https://laravel.com/docs/migrations). -- [Robust background job processing](https://laravel.com/docs/queues). -- [Real-time event broadcasting](https://laravel.com/docs/broadcasting). - -Laravel is accessible, powerful, and provides tools required for large, robust applications. - -## Learning Laravel - -Laravel has the most extensive and thorough [documentation](https://laravel.com/docs) and video tutorial library of all modern web application frameworks, making it a breeze to get started with the framework. - -In addition, [Laracasts](https://laracasts.com) contains thousands of video tutorials on a range of topics including Laravel, modern PHP, unit testing, and JavaScript. Boost your skills by digging into our comprehensive video library. - -You can also watch bite-sized lessons with real-world projects on [Laravel Learn](https://laravel.com/learn), where you will be guided through building a Laravel application from scratch while learning PHP fundamentals. - -## Agentic Development - -Laravel's predictable structure and conventions make it ideal for AI coding agents like Claude Code, Cursor, and GitHub Copilot. Install [Laravel Boost](https://laravel.com/docs/ai) to supercharge your AI workflow: +## First-run setup ```bash -composer require laravel/boost --dev - -php artisan boost:install +cp .env.example .env # dev defaults work as-is +docker compose build # build the app image +docker compose run --rm app bash docker/app/bootstrap.sh # deps + key + assets + migrate/seed +docker compose up -d # start the full stack ``` -Boost provides your agent 15+ tools and skills that help agents build Laravel applications while following best practices. +> `docker compose up` alone is **not** the first command — `vendor/`, `node_modules` +> and `public/build` are not committed, so the bootstrap step above must run first. -## Contributing +Then open **http://localhost** and sign in with the seeded dev admin: -Thank you for considering contributing to the Laravel framework! The contribution guide can be found in the [Laravel documentation](https://laravel.com/docs/contributions). +- **admin@homeos.local** / **homeos-dev** ← change this for anything but local dev. -## Code of Conduct +For production, set strong values in `.env` for `DB_PASSWORD`, the `REVERB_APP_*` +keys and `HOMEOS_ADMIN_PASSWORD`, and run `php artisan key:generate`. -In order to ensure that the Laravel community is welcoming to all, please review and abide by the [Code of Conduct](https://laravel.com/docs/contributions#code-of-conduct). +## Everyday commands (in-container, R8) -## Security Vulnerabilities +```bash +docker compose exec app php artisan … # artisan +docker compose exec app composer … # composer +docker compose exec app npm run build # rebuild assets (or `npm run dev` for HMR) +docker compose exec app php artisan test # test suite +docker compose logs -f app # logs +``` -If you discover a security vulnerability within Laravel, please send an e-mail to Taylor Otwell via [taylor@laravel.com](mailto:taylor@laravel.com). All security vulnerabilities will be promptly addressed. +## Services & ports -## License +| Service | Role | Host port | +|---|---|---| +| `app` | php-fpm + nginx + supervisor | `${APP_PORT:-80}` | +| `reverb` | websockets (proxied same-origin via nginx `/app`) | `${REVERB_HOST_PORT:-6001}` | +| `horizon` · `scheduler` | queue workers · cron | — | +| `db` | PostgreSQL 17 + TimescaleDB | `127.0.0.1:${DB_HOST_PORT:-5432}` | +| `redis` | cache / queue | — | -The Laravel framework is open-sourced software licensed under the [MIT license](https://opensource.org/licenses/MIT). +All ports and `HOST_UID`/`HOST_GID` are env-driven in `.env`. diff --git a/database/seeders/DatabaseSeeder.php b/database/seeders/DatabaseSeeder.php index 5cc47b7..d01e96e 100644 --- a/database/seeders/DatabaseSeeder.php +++ b/database/seeders/DatabaseSeeder.php @@ -15,11 +15,15 @@ class DatabaseSeeder extends Seeder */ public function run(): void { + // `?:` (not env's 2nd arg) so a present-but-empty HOMEOS_ADMIN_PASSWORD can never + // seed a blank-password admin — it falls back to a non-empty dev default. + $adminPassword = env('HOMEOS_ADMIN_PASSWORD') ?: 'homeos-dev'; + User::updateOrCreate( ['email' => env('HOMEOS_ADMIN_EMAIL', 'admin@homeos.local')], [ 'name' => env('HOMEOS_ADMIN_NAME', 'Admin'), - 'password' => Hash::make(env('HOMEOS_ADMIN_PASSWORD', 'homeos-dev')), + 'password' => Hash::make($adminPassword), 'email_verified_at' => now(), ], ); diff --git a/docker/app/bootstrap.sh b/docker/app/bootstrap.sh new file mode 100755 index 0000000..0b9bb8e --- /dev/null +++ b/docker/app/bootstrap.sh @@ -0,0 +1,28 @@ +#!/usr/bin/env bash +# +# One-time first-run bootstrap. The repo does not vendor `vendor/`, `node_modules` +# or `public/build`, so these must be installed before the app-family services +# (app, horizon, scheduler, reverb) run `artisan`. +# +# Run after `docker compose build`, before `docker compose up`: +# docker compose run --rm app bash docker/app/bootstrap.sh +# +set -euo pipefail +cd /var/www/html + +echo "→ composer install" +composer install --no-interaction --prefer-dist + +if ! grep -q '^APP_KEY=base64:' .env; then + echo "→ php artisan key:generate" + php artisan key:generate --force +fi + +echo "→ npm ci + build assets" +npm ci +npm run build + +echo "→ migrate + seed (mock home)" +php artisan migrate --force --seed + +echo "✓ bootstrap complete — start the stack with: docker compose up -d"