diff --git a/README.md b/README.md index e99229f..a6a3e08 100644 --- a/README.md +++ b/README.md @@ -40,12 +40,14 @@ DB_ADMIN_TOOL=phpmyadmin ``` Then run `start.sh`. Enjoy!๐ŸŽ‰๐Ÿš€ +To stop the stack run `stop.sh`. Refer to [PHP-CRUD-API](https://github.com/mevdschee/php-crud-api) for further customizations. ## REQUIREMENTS: - Any host runnign [Docker](https://docs.docker.com/engine/install/) and [Docker Compose](https://docs.docker.com/compose/install/). -In case your running your instance on localhost and your selected port is 8080 +In case your running your instance on localhost and your selected port is 8080. + **Your `tests` table will be available at** http://127.0.0.1:8080/records/tests (no need of explicit api.php)[^1] **Your MYSQL ADMIN instance will be available at** diff --git a/stop.sh b/stop.sh new file mode 100755 index 0000000..b2b8466 --- /dev/null +++ b/stop.sh @@ -0,0 +1,33 @@ +#!/bin/bash + +# Carica le variabili d'ambiente dal file .env +export $(grep -v '^#' .env | xargs) + +# Funzione per calcolare la porta del DB admin tool +calculate_db_admin_port() { + if [ "$DB_ADMIN_TOOL" = "adminer" ]; then + echo "8080" + elif [ "$DB_ADMIN_TOOL" = "phpmyadmin" ]; then + echo "80" + else + echo "80" # Valore di default + fi +} + +# Calcola la porta del DB admin tool +DB_ADMIN_PORT=$(calculate_db_admin_port) +export DB_ADMIN_PORT + +# Verifica quale tool di amministrazione del database รจ stato selezionato +if [ "$DB_ADMIN_TOOL" = "adminer" ]; then + echo "Arresto dei servizi con Adminer..." + docker compose --profile adminer down +elif [ "$DB_ADMIN_TOOL" = "phpmyadmin" ]; then + echo "Arresto dei servizi con PhpMyAdmin..." + docker compose --profile phpmyadmin down +else + echo "Errore: DB_ADMIN_TOOL non valido. Usa 'adminer' o 'phpmyadmin'." + exit 1 +fi + +echo "Servizi avviati con successo!" \ No newline at end of file