fix: restore Docker env settings and auto-seed on container start
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
APP_NAME=Laravel
|
||||
APP_ENV=local
|
||||
APP_KEY=base64:OFp3XAt51AYn58z/kilW0gmM4zt9A9Onr839QdWLCvM=
|
||||
APP_KEY=base64:LT9slFZW4kFTXKm807LCwYoCFDx97HdCQZ1kf1HpvqQ=
|
||||
APP_DEBUG=true
|
||||
APP_URL=http://localhost
|
||||
|
||||
@@ -21,12 +21,11 @@ LOG_DEPRECATIONS_CHANNEL=null
|
||||
LOG_LEVEL=debug
|
||||
|
||||
DB_CONNECTION=mysql
|
||||
DB_HOST=127.0.0.1
|
||||
DB_HOST=mysql
|
||||
DB_PORT=3306
|
||||
DB_DATABASE=webgis_miskin
|
||||
DB_USERNAME=root
|
||||
DB_PASSWORD=
|
||||
|
||||
DB_USERNAME=webgis
|
||||
DB_PASSWORD=secret
|
||||
|
||||
SESSION_DRIVER=database
|
||||
SESSION_LIFETIME=120
|
||||
|
||||
@@ -0,0 +1,73 @@
|
||||
# Docker Development
|
||||
|
||||
This setup runs the Laravel app, Vite, and MySQL through Docker Compose.
|
||||
|
||||
## Services
|
||||
|
||||
- Laravel app: `http://localhost:8000`
|
||||
- Vite dev server: `http://localhost:5173`
|
||||
- MySQL from host: `127.0.0.1:3307`
|
||||
- MySQL from containers: `mysql:3306`
|
||||
|
||||
## First Run
|
||||
|
||||
If you want Docker to own the Laravel environment values, copy the Docker example:
|
||||
|
||||
```powershell
|
||||
Copy-Item .env.docker.example .env
|
||||
```
|
||||
|
||||
Then start everything:
|
||||
|
||||
```powershell
|
||||
docker compose up -d --build
|
||||
```
|
||||
|
||||
The app container installs Composer dependencies, generates `APP_KEY` if needed, clears config, runs migrations, and seeds the database (roles + default admin account).
|
||||
|
||||
The Vite container installs Node dependencies and starts the dev server.
|
||||
|
||||
## Useful Commands
|
||||
|
||||
```powershell
|
||||
docker compose ps
|
||||
docker compose logs -f app
|
||||
docker compose logs -f vite
|
||||
docker compose exec app php artisan migrate:status
|
||||
docker compose exec app php artisan test
|
||||
docker compose down
|
||||
```
|
||||
|
||||
To remove the MySQL data volume and start with a clean database:
|
||||
|
||||
```powershell
|
||||
docker compose down -v
|
||||
```
|
||||
|
||||
## Database Credentials
|
||||
|
||||
```text
|
||||
Database: webgis_miskin
|
||||
Username: webgis
|
||||
Password: secret
|
||||
Root password: root
|
||||
```
|
||||
|
||||
## Default Login
|
||||
|
||||
After first run, akses `http://localhost:8000` dan login dengan:
|
||||
|
||||
```text
|
||||
Email: admin@webgis.local
|
||||
Password: admin123
|
||||
```
|
||||
|
||||
## Roles yang Tersedia
|
||||
|
||||
| Role | Akses |
|
||||
|---|---|
|
||||
| `administrator` | Akses penuh |
|
||||
| `pengurus_ibadah` | Kelola data rumah ibadah |
|
||||
| `petugas_pendataan` | Input/edit data keluarga miskin |
|
||||
| `pemangku_kebijakan` | View only |
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
#!/usr/bin/env sh
|
||||
set -e
|
||||
|
||||
cd /var/www/html
|
||||
|
||||
if [ ! -f .env ] && [ -f .env.docker.example ]; then
|
||||
cp .env.docker.example .env
|
||||
fi
|
||||
|
||||
if [ ! -f vendor/autoload.php ]; then
|
||||
composer install
|
||||
fi
|
||||
|
||||
php artisan config:clear --no-ansi
|
||||
|
||||
if ! grep -q '^APP_KEY=base64:' .env 2>/dev/null; then
|
||||
php artisan key:generate --force --no-ansi
|
||||
fi
|
||||
|
||||
php artisan migrate --force --no-ansi
|
||||
php artisan db:seed --force --no-ansi
|
||||
|
||||
exec "$@"
|
||||
Reference in New Issue
Block a user