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 <noreply@anthropic.com>
feat/phase-1-bootstrap
HomeOS Bootstrap 2026-07-17 21:24:10 +02:00
parent fcb6daa6ab
commit 1b69c39a93
4 changed files with 67 additions and 45 deletions

View File

@ -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

View File

@ -1,58 +1,48 @@
<p align="center"><a href="https://laravel.com" target="_blank"><img src="https://raw.githubusercontent.com/laravel/art/master/logo-lockup/5%20SVG/2%20CMYK/1%20Full%20Color/laravel-logolockup-cmyk-red.svg" width="400" alt="Laravel Logo"></a></p>
# HomeOS
<p align="center">
<a href="https://github.com/laravel/framework/actions"><img src="https://github.com/laravel/framework/workflows/tests/badge.svg" alt="Build Status"></a>
<a href="https://packagist.org/packages/laravel/framework"><img src="https://img.shields.io/packagist/dt/laravel/framework" alt="Total Downloads"></a>
<a href="https://packagist.org/packages/laravel/framework"><img src="https://img.shields.io/packagist/v/laravel/framework" alt="Latest Stable Version"></a>
<a href="https://packagist.org/packages/laravel/framework"><img src="https://img.shields.io/packagist/l/laravel/framework" alt="License"></a>
</p>
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`.

View File

@ -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(),
],
);

28
docker/app/bootstrap.sh Executable file
View File

@ -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"