Skip to content

Commit

Permalink
Housekeeping, removed debugging code, cleaned up env vars.
Browse files Browse the repository at this point in the history
  • Loading branch information
madsem committed Jun 6, 2024
1 parent c37b565 commit e8e8f50
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 24 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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/
Expand All @@ -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`.

Expand Down
42 changes: 21 additions & 21 deletions bin/phpdock
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down Expand Up @@ -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 "$@"
Expand Down Expand Up @@ -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."
Expand All @@ -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 <service>"
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
2 changes: 1 addition & 1 deletion src/.env.phpdock
Original file line number Diff line number Diff line change
@@ -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
1 change: 0 additions & 1 deletion src/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/docker/singlestore/docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"


Expand Down

0 comments on commit e8e8f50

Please sign in to comment.