diff --git a/README.md b/README.md index fcd3ffb..a0d9639 100644 --- a/README.md +++ b/README.md @@ -9,6 +9,8 @@ Including: `php-fpm`, `MySql`,, `Singlestore`, `Redis`, `Nginx`, `Mailhog`, `Composer`, `node`, `npm` & `yarn` +Deafults to Singlestore DB. + # Local Addresses - Mailhog: * http://localhost:8025/ @@ -24,6 +26,7 @@ Use any of these in `.env.phpdock`, to customize your environment: - PHP-fpm: 8.3-latest - MySql Server: any valid mysql tag between 5.7 - 8.x - singlestore: always latest version +- redis: always latest version To customize more, you can always edit the `docker-compose,yml`. diff --git a/bin/phpdock b/bin/phpdock index 98261af..78b96c5 100755 --- a/bin/phpdock +++ b/bin/phpdock @@ -14,11 +14,6 @@ if [ -f .env.phpdock ]; then set +o allexport fi -# Debug: Print environment variables -echo "DB_NAME: $DB_NAME" -echo "DB_USER: $DB_USER" -echo "DB_PASS: $DB_PASS" - # Files to be published to project root PHPDOCK_FILES=".env.phpdock docker-compose.yml .dockerignore" @@ -151,9 +146,9 @@ else # If "composer" is used, pass-thru to "composer" # inside a new container - elif [ "${1:-}" == "composer" ] || [ "${1:-}" == "comp" ] || [ "${1:-}" == "com" ]; then + elif [ "${1:-}" == "composer" ] || [ "${1:-}" == "comp" ] || [ "${1:-}" == "com" ];then shift - if [ "$EXEC" == "yes" ]; then + if [ "$EXEC" == "yes" ];then $COMPOSE exec -u phpdock app composer "$@" else $COMPOSE run --rm -u phpdock app composer "$@" @@ -198,7 +193,7 @@ else elif [ "${1:-}" == "mysql" ];then shift if [ "$EXEC" == "yes" ];then - $COMPOSE exec mysql /bin/sh -c 'MYSQL_PWD=$DB_PASS mysql -u $DB_USER $DB_NAME' + $COMPOSE exec mysql /bin/sh -c "MYSQL_PWD=\"$DB_PASS\" mysql -u \"$DB_USER\" -D \"$DB_NAME\"" else echo "Error: This command can only be run while a MySQL container is running mysqld (mysql server)." echo "This command cannot run the server and the mysql client at the same time." @@ -208,28 +203,33 @@ else elif [ "${1:-}" == "singlestore" ]; then shift if [ "$EXEC" == "yes" ]; then - $COMPOSE exec singlestore /bin/sh -c "MYSQL_PWD=\"$ROOT_PASSWORD\" memsql -u \"$DB_USER\" -D \"$DB_NAME\"" + $COMPOSE exec singlestore /bin/sh -c "MYSQL_PWD=\"$DB_PASS\" memsql -u \"$DB_USER\" -D \"$DB_NAME\"" else echo "Error: This command can only be run while a SingleStore container is running." fi + # If "ssh" is used, log into this service as phpdock user + elif [ "${1:-}" == "ssh" ]; then + SERVICE="${2:-}" + if [ -z "$SERVICE" ]; then + echo "Error: No service specified. Usage: phpdock ssh " + exit 1 + fi - - # If "ssh" is used, pass-thru to "ssh" inside a new container - elif [ "${1:-}" == "ssh" ];then - shift - if [ "$EXEC" == "yes" ] && [ "$1" != "redis" ];then - echo "Logging you in a shell as phpdock user:" - $COMPOSE exec -u phpdock "$1" /bin/sh - elif [ "$EXEC" == "yes" ] && [ "$1" == "redis" ];then - $COMPOSE exec "$1" redis-cli + if [ "$EXEC" == "yes" ]; then + if [ "$SERVICE" == "redis" ]; then + $COMPOSE exec "$SERVICE" redis-cli + else + echo "Log into a shell as phpdock user:" + $COMPOSE exec -u phpdock "$SERVICE" /bin/sh + fi else - $COMPOSE exec "$1" /bin/sh + echo "Error: The specified service is not running." + exit 1 fi # Else, pass-thru args to docker-compose else $COMPOSE "$@" fi - -fi +fi \ No newline at end of file diff --git a/src/.env.phpdock b/src/.env.phpdock index 8eda57b..fae4a30 100644 --- a/src/.env.phpdock +++ b/src/.env.phpdock @@ -1,10 +1,10 @@ # Docker Configuration PHP_VERSION=8.3-latest -REDIS_VERSION=5.0.12-alpine WEB_PORT=80 +# DB DB_NAME=phpdock DB_USER=root DB_PASS=secret diff --git a/src/docker-compose.yml b/src/docker-compose.yml index db33f90..40e4d58 100644 --- a/src/docker-compose.yml +++ b/src/docker-compose.yml @@ -48,7 +48,6 @@ services: ROOT_PASSWORD: ${DB_PASS:-secret} DB_NAME: ${DB_NAME:-phpdock} DB_USER: ${DB_USER:-phpdock} - DB_PASS: ${DB_PASS:-secret} depends_on: singlestore: condition: service_healthy diff --git a/src/docker/singlestore/docker-entrypoint.sh b/src/docker/singlestore/docker-entrypoint.sh index f3a3d7d..ff07521 100755 --- a/src/docker/singlestore/docker-entrypoint.sh +++ b/src/docker/singlestore/docker-entrypoint.sh @@ -4,7 +4,7 @@ set -e set -u set -o pipefail -url="root:${ROOT_PASSWORD}@singlestore:9000/api/v1/query/rows" +url="root:${DB_PASS}@singlestore:9000/api/v1/query/rows" header="content-type: application/json"