From 0395b68d33afcf257515d5c769e60b358b2699bb Mon Sep 17 00:00:00 2001 From: Oliver Davies Date: Sat, 20 Jul 2024 13:57:08 +0100 Subject: [PATCH] Update build configuration files --- .env.example | 4 ++++ run | 13 +++++++++++++ 2 files changed, 17 insertions(+) diff --git a/.env.example b/.env.example index 66de1a2..a211cef 100644 --- a/.env.example +++ b/.env.example @@ -12,3 +12,7 @@ export DRUSH_OPTIONS_URI="https://${COMPOSE_PROJECT_NAME}.docker.localhost" export MYSQL_DATABASE=app export MYSQL_PASSWORD=app export MYSQL_USER=app + +export DB_NAME="$MYSQL_DATABASE" +export DB_PASSWORD="$MYSQL_PASSWORD" +export DB_USER="$MYSQL_USER" diff --git a/run b/run index ca8b05d..090690d 100755 --- a/run +++ b/run @@ -38,18 +38,29 @@ function cmd { } +# Execute any Composer command. function composer { _exec php composer "${@}" } +# Connect to the database. +function db { + [[ -f ".env" ]] && source .env + + docker compose exec database mysql -u"$DB_USER" -p"$DB_PASSWORD" "$DB_NAME" +} + +# Execute any Drush command. function drush { _exec php drush "${@}" } +# Disable Git hooks. function git-hooks:off { git config --unset core.hooksPath } +# Enable Git hooks. function git-hooks:on { git config core.hooksPath .githooks } @@ -68,12 +79,14 @@ function install { drush site:install -y "${@}" } +# Lint the Dockerfile. function lint:dockerfile { docker container run --rm -i \ hadolint/hadolint hadolint --ignore DL3008 --ignore DL3022 --ignore DL3059 -t style "${@}" - < Dockerfile } +# Start the project. function start { cp -v --no-clobber .env.example .env || true