Example for https://www.ogsoft.cz/ based on Laravel
app | ||
bootstrap | ||
config | ||
database | ||
docker | ||
public | ||
resources | ||
routes | ||
storage | ||
tests | ||
.editorconfig | ||
.env.example | ||
.gitattributes | ||
.gitignore | ||
artisan | ||
composer.json | ||
composer.lock | ||
develop.sh | ||
docker-compose.yml | ||
Dockerfile.fpm | ||
Dockerfile.nginx | ||
Dockerfile.static | ||
package.json | ||
phpcs.xml.dist | ||
phpstan.neon.dist | ||
phpunit.xml | ||
README.md | ||
vite.config.js |
How to start with development
- Run:
develop.sh
- Enjoy your coffee ;-)
- Laravel will serve web at [http://localhost:8000] (which redirect to API documentation)
- Requirements: Docker, Docker Compose v2, Bash
How to try API
- for example, via swagger ([http://localhost:8000/api/documentation])
How to create Czech public holidays:
docker compose exec -it php-fpm /var/www/html/artisan app:create-holidays CZ 2024
Tests
docker compose exec --env OTEL_PHP_DISABLED_INSTRUMENTATIONS=all php-fpm vendor/bin/phpunit
phpstan & cs
docker compose exec --env OTEL_PHP_DISABLED_INSTRUMENTATIONS=all php-fpm vendor/bin/phpcs
docker compose exec --env OTEL_PHP_DISABLED_INSTRUMENTATIONS=all php-fpm vendor/bin/phpstan --memory-limit=2G
Swagger:
regenerate swagger:
docker compose exec -it php-fpm /var/www/html/artisan l5-swagger:generate
Logs:
- Logs in storage/logs/laravel.log file
Traces:
- Traces are saved into Tempo and are available via Grafana at http://localhost:3000
Containers:
- php-fpm -> FPM and tooling
- nginx -> Serving static content, proxy to FPM
- mysql -> Database
- grafana, tempo, loki, promtail, prometheus -> Monitoring stack
TODO:
- Logs into loki
- Better traces in Tempo (currently very basic)
- Monitor the result of refresh-database via Prometheus
- Monitor status codes via Prometheus
- Sentry integration
- Deployment to dev/test and prod, production settings, production Docker images
- CI/CD
Notes
In real "production" code, the monitoring stack will be available from the dev/test environment. It doesn't make sense to have it on the local dev stack, but for this example, I thought it was good