- PHP 71.4%
- Blade 28.1%
- Makefile 0.3%
- Dockerfile 0.1%
| Filename | Latest commit message | Latest commit date |
|---|---|---|
fix(me): align PelupusanAggregator with PKH controllers, no controller changes See merge request shukry-datakraf/myinfra-pkh!28 |
||
| app | ||
| bootstrap | ||
| config | ||
| database | ||
| docker | ||
| k8s | ||
| public | ||
| resources | ||
| routes | ||
| storage | ||
| tests | ||
| .editorconfig | ||
| .env.example | ||
| .env.testing | ||
| .gitattributes | ||
| .gitignore | ||
| .gitlab-ci.yml | ||
| artisan | ||
| composer.json | ||
| composer.lock | ||
| docker-compose.test.yml | ||
| docker-compose.yml | ||
| Dockerfile | ||
| Dockerfile.ci | ||
| Dockerfile.local | ||
| Makefile | ||
| package.json | ||
| phpunit.xml | ||
| README.md | ||
| vite.config.js | ||
MyInfra PKH (Pelupusan & Hapus Kira)
Backend microservice for Modul Pelupusan & Hapus Kira (Disposal & Write-off).
| Framework | Laravel 12 |
| Port | 8010 |
| Database | myinfradb_pkh (PostgreSQL) |
| Auth | Keycloak (RS256 JWT) |
| API Prefix | /api/pkh |
| Container | myinfra-pkh |
| K8s Namespace | myinfra-pkh |
Prerequisites
- Docker & Docker Compose
myinfra-pgsnservice running (provides shared PostgreSQL, Redis, Keycloak, MinIO)myinfra-corepackage cloned at../myinfra-core
Setup
1. Clone the repository
cd /path/to/myinfra-2
git clone [email protected]:shukry-datakraf/myinfra-pkh.git
cd myinfra-pkh
2. Environment configuration
cp .env.example .env
Edit .env if needed. The defaults work for local development with myinfra-pgsn.
3. Install dependencies
composer install --ignore-platform-req=ext-mongodb
Note: The
--ignore-platform-req=ext-mongodbflag is needed because the MongoDB extension is installed inside Docker, not on the host machine.
4. Create the database
Make sure myinfra-pgsn is running, then create the PKH database:
docker exec -it myinfra-pgsn-pgsql psql -U postgres -c "CREATE DATABASE myinfradb_pkh;"
On fresh
myinfra-pgsnsetups, this database is created automatically viadocker/init/multi-db-init.sql.
5. Start the service
docker compose up -d
6. Run migrations
docker compose exec myinfra-pkh php artisan migrate
7. Verify
curl http://localhost:8010/api/health
# {"status":"ok","service":"myinfra-pkh","timestamp":"..."}
curl http://localhost:8010/api/test/database
# {"status":"ok","message":"Database connection successful","database":"pgsql"}
Make Commands
| Command | Description |
|---|---|
make up |
Start the container |
make down |
Stop the container |
make restart |
Restart the container |
make bash |
Shell into the container |
make migrate |
Run database migrations |
make fresh |
Fresh migration with seeds |
make logs |
View container logs |
make app-log |
View nginx/php-fpm logs |
make queue-log |
View queue worker logs |
make cache-clear |
Clear all Laravel caches |
make test |
Run PHPUnit tests |
make status |
Show container status |
Run make help for the full list.
Project Structure
myinfra-pkh/
├── app/
│ ├── Helpers/helpers.php # getCurrentUser(), auth helpers
│ ├── Http/
│ │ ├── Controllers/ # API controllers
│ │ └── Middleware/ # Keycloak auth middleware
│ ├── Models/ # Eloquent models
│ │ ├── User.php # Uses pgsql-pgsn (read-only)
│ │ └── Pegawai.php # Uses pgsql-pgsn (read-only)
│ └── Providers/
│ └── AppServiceProvider.php # Service bindings
├── config/
│ ├── auth.php # Keycloak guard config
│ ├── cors.php # CORS policy
│ ├── database.php # pgsql + pgsql-pgsn + mongodb
│ └── keycloak.php # Keycloak JWT settings
├── docker/
│ ├── nginx.conf # Nginx config
│ ├── supervisord.conf # Process manager
│ ├── php.ini # PHP settings
│ ├── entrypoint.sh # Production entrypoint
│ └── entrypoint-local.sh # Local dev entrypoint
├── k8s/
│ ├── staging/ # K8s manifests (staging)
│ └── production/ # K8s manifests (production)
├── routes/api.php # API routes
├── docker-compose.yml # Local development
├── Dockerfile # Production image
├── Dockerfile.local # Local dev image
├── Dockerfile.ci # CI testing image
├── .gitlab-ci.yml # CI/CD pipeline
└── Makefile # Developer commands
Database Connections
| Connection | Database | Purpose |
|---|---|---|
pgsql (default) |
myinfradb_pkh |
PKH module data |
pgsql-pgsn |
myinfradb_pgsn |
Shared users/pegawai (read-only) |
API Endpoints
Public
| Method | Endpoint | Description |
|---|---|---|
| GET | /api/health |
Health check |
| GET | /api/test |
Service status |
| POST | /api/test/echo |
Echo request data |
| GET | /api/test/database |
Database connection test |
Protected (requires Keycloak token)
| Method | Endpoint | Description |
|---|---|---|
| - | /api/pkh/* |
PKH module routes (TBD) |
CI/CD
The GitLab pipeline (.gitlab-ci.yml) runs on staging, training, and production branches:
- prebuild-test - Build CI test image
- test - PHPUnit with PostgreSQL
- build - Docker production image
- deploy - Deploy to K8s (
myinfra-pkhnamespace) - rollback - Manual rollback option
Troubleshooting
Container crashes on startup
Check if myinfra-pgsn is running — PKH depends on the shared Docker network:
cd ../myinfra-pgsn && docker compose ps
PHP version mismatch
If you see Your Composer dependencies require a PHP version ">= 8.4.0", your host PHP is newer than Docker's PHP 8.2. Fix:
composer config platform.php 8.2.30
rm -rf vendor composer.lock
composer install --ignore-platform-req=ext-mongodb
Database connection refused
Ensure the database exists:
docker exec -it myinfra-pgsn-pgsql psql -U postgres -l | grep myinfradb_pkh