Skip to content

Commit

Permalink
1.1.2 - parametric dbadmin
Browse files Browse the repository at this point in the history
  • Loading branch information
nik2208 committed Oct 17, 2024
1 parent bbdf605 commit 2879691
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 1 deletion.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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**
Expand Down
33 changes: 33 additions & 0 deletions stop.sh
Original file line number Diff line number Diff line change
@@ -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!"

0 comments on commit 2879691

Please sign in to comment.