Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Created interactive DDEV setup #14

Open
wants to merge 32 commits into
base: 4.6
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
98ce2c2
Created interactive DDEV setup
webhdx Mar 12, 2024
489a53a
Updated Ibexa banner
webhdx May 10, 2024
8ab8240
Made ibexa-setup.sh to ddev host script
webhdx Jun 11, 2024
e888014
Set terminal colors independent from host
webhdx Jun 11, 2024
50f7de5
Use `ibexa/ddev-solr` addon
webhdx Jun 11, 2024
d80eb7c
Fixed Redis 7 setup
webhdx Jun 11, 2024
0417080
Removed workaround for Varnish setup
webhdx Jun 11, 2024
b0ce82e
Moved util functions to .utils script
webhdx Jun 11, 2024
1d0b68a
Added ibexa-post-setup command
webhdx Jun 11, 2024
b1abd44
Prompt for credentials when updates.ibexa.co cannot be accessed
webhdx Jun 27, 2024
cb09b74
Install ibexa/test-fixtures in dev version
webhdx Jun 27, 2024
e4e3ec5
Minor cleanups in ibexa-installer
webhdx Jun 27, 2024
1f62f8e
ibexa-configurator: Dump env variables to settings file in a nicer way
webhdx Jun 27, 2024
386daec
ibexa-post-setup: Prevent running post-setup on every restart
webhdx Jun 27, 2024
dc653ea
ibexa-configurator: Improved displaying setup details
webhdx Jun 27, 2024
1521837
ibexa-installer: Check if ibexa/test-fixtures can be installed before…
webhdx Jun 27, 2024
68d1ec8
ibexa-installer: Check updates.ibexa.co auth problems
webhdx Jun 28, 2024
18c746a
ibexa-installer: Check updates.ibexa.co auth problems
webhdx Jun 28, 2024
4859671
ibexa-post-setup: Removed post-setup step
webhdx Jun 28, 2024
01a274f
ibexa-installer: Minor text corrections
webhdx Jun 28, 2024
30c8dfa
ibexa-installer: Added spinner during auth check
webhdx Jun 28, 2024
a7a5060
ibexa-installer: Added status message on successful auth
webhdx Jun 28, 2024
15b53f1
ibexa-installer: Improved text readability
webhdx Jun 28, 2024
dcae97c
ibexa-configurator: Introduce flag to distinguish installations from …
webhdx Jul 12, 2024
b061aa2
ibexa-installer: Use different installation workflow for product skel…
webhdx Jul 12, 2024
f2d8c74
ibexa-installer: Fix for installing from composer.lock
webhdx Jul 12, 2024
652c235
ibexa-installer: Streamlined code style
webhdx Jul 12, 2024
68f1abb
ibexa-setup: Streamlined code style
webhdx Jul 12, 2024
0e54432
ibexa-configurator: Fix for displaying yes/no values
webhdx Jul 12, 2024
e21a2ea
ibexa-configurator: Reorder setup questions
webhdx Jul 12, 2024
d00cf27
ibexa-installer: Use composer update when using PHP 8.1
webhdx Jul 12, 2024
46cb18d
ibexa-installer: Code style
webhdx Jul 12, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions .ddev/commands/host/.utils
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/bash

function verbose_output() {
if [ "$VERBOSE_INSTALL" = true ]; then
"$@"
else
"$@" > /dev/null
fi
}
164 changes: 164 additions & 0 deletions .ddev/commands/host/ibexa-setup
Original file line number Diff line number Diff line change
@@ -0,0 +1,164 @@
#!/bin/bash

## #ddev-generated
## Description: This script reads settings from `ddev ibexa-configurator` and sets up ddev
## Usage: ibexa-setup
## Example: ddev ibexa-setup

source .ddev/commands/host/.utils

[ -z "$SETTINGS_FILE" ] && SETTINGS_FILE="./.ddev/.ibexa-instance-settings"
[ -z "$PROVISION_FILE_GENERAL" ] && PROVISION_FILE_GENERAL="./.ddev/.ibexa-setup-general-provisioned"
[ -z "$PROVISION_FILE_SERVICES" ] && PROVISION_FILE_SERVICES="./.ddev/.ibexa-setup-services-provisioned"
[ -z "$VERBOSE_INSTALL" ] && VERBOSE_INSTALL=false

if [ "$VERBOSE_INSTALL" != false ] && [ ! -f "$PROVISION_FILE_GENERAL" ] && [ ! -f "$PROVISION_FILE_SERVICES" ]; then
clear
fi

if [ ! -f "$SETTINGS_FILE" ]; then
echo "Settings file does not exist, run ddev ibexa-configurator first."
exit 1
fi

source $SETTINGS_FILE

if [ ! -f "$PROVISION_FILE_GENERAL" ]; then
# Project name
ddev config --project-name="$DDEV_SITENAME"

# PHP
echo "php_version: $PHP_VERSION" > .ddev/config.php.yaml
echo "👷 Configured PHP version: $PHP_VERSION"

# NodeJS
echo "nodejs_version: $NODE_VERSION" > .ddev/config.node.yaml
echo "👷 Configured Node version: $NODE_VERSION"

# Web Server
if [ "$HTTP_SERVER" = "apache-fpm" ]
then
echo "webserver_type: $HTTP_SERVER" > .ddev/config.http.yaml
fi
echo "👷 Configured HTTP server: $HTTP_SERVER"

# Database
echo "database:
type: $DATABASE
version: $DATABASE_VERSION" > .ddev/config.db.yaml
echo "👷 Configured Database: $DATABASE:$DATABASE_VERSION"

# App env
echo "APP_ENV=$APP_ENV" >> .env.local
if [ "$APP_ENV" = "prod" ]; then
echo "APP_DEBUG=0" >> .env.local
else
echo "APP_DEBUG=1" >> .env.local
fi
echo "👷 Configured app environment: $APP_ENV"

echo "👷 Restarting ddev project to reflect webserver and database changes"

touch "$PROVISION_FILE_GENERAL"

verbose_output ddev restart
fi

if [ -f "$PROVISION_FILE_SERVICES" ]; then
exit 0
fi

DB_SCHEME=mysql
DB_USER=db
DB_PASS=db
DB_NAME=db
DB_HOST=db
DB_PORT=3306
DB_VERSION=$DATABASE_VERSION
DB_CHARSET=utf8mb4
DB_COLLATION=utf8mb4_unicode_520_ci

if [ "$DATABASE" == "mariadb" ]; then
DB_VERSION=mariadb-`ddev exec -s db mysql -V | awk '{print $5}' | sed 's/-.*//'`
fi

if [ "$DATABASE" == "postgres" ]; then
DB_PORT=5432
DB_SCHEME=postgresql
DB_CHARSET=utf8
DB_COLLATION=utf8_unicode_ci
fi

echo "# " >> .env.local
echo "# dxp-installer generated" >> .env.local
echo "DATABASE_URL=${DB_SCHEME}://${DB_USER}:${DB_PASS}@${DB_HOST}:${DB_PORT}/${DB_NAME}?serverVersion=${DB_VERSION}&charset=${DB_CHARSET}" >> .env.local
echo "DATABASE_VERSION=${DB_VERSION}" >> .env.local
echo "DATABASE_CHARSET=${DB_CHARSET}" >> .env.local
echo "DATABASE_COLLATION=${DB_COLLATION}" >> .env.local

echo "👷 Saved database details in .env.local"

if [ "$HTTP_CACHE" == "varnish" ]; then
echo "# " >> .env.local
echo "# dxp-installer generated" >> .env.local
echo "TRUSTED_PROXIES=REMOTE_ADDR" >> .env.local
echo "HTTPCACHE_PURGE_TYPE=varnish" >> .env.local
echo "HTTPCACHE_PURGE_SERVER=$DDEV_PRIMARY_URL" >> .env.local

verbose_output ddev get reithor/ddev-varnish
fi

echo "👷 Configured HTTP cache: $HTTP_CACHE"

# Memcached
if [ "$APP_CACHE" == "memcached" ]; then
echo "# " >> .env.local
echo "# dxp-installer generated" >> .env.local
echo "CACHE_POOL=\"cache.memcached\"" >> .env.local
echo "CACHE_DSN=\"memcached:11211?weight=33\"" >> .env.local

verbose_output ddev get ddev/ddev-memcached
fi

# Redis
if [ "$APP_CACHE" == "redis" ]; then
echo "# " >> .env.local
echo "# dxp-installer generated" >> .env.local
echo "CACHE_POOL=cache.redis" >> .env.local
echo "CACHE_DSN=redis@redis:6379" >> .env.local

verbose_output ddev get ddev/ddev-redis-7

echo "# " >> .ddev/redis/memory.conf
echo "# dxp-installer generated" >> .ddev/redis/memory.conf
echo "maxmemory-policy volatile-lfu" >> .ddev/redis/memory.conf
fi

echo "👷 Configured app cache: $APP_CACHE"

# Solr
if [ "$SEARCH_ENGINE" == "solr" ]; then
echo "# " >> .env.local
echo "# dxp-installer generated" >> .env.local
echo "SEARCH_ENGINE=solr" >> .env.local
echo "SOLR_CORE=collection1" >> .env.local
echo "SOLR_DSN=http://solr:8983/solr" >> .env.local

verbose_output ddev get ibexa/ddev-solr
fi

# Elasticsearch
if [ "$SEARCH_ENGINE" == "elasticsearch" ]; then
echo "# " >> .env.local
echo "# dxp-installer generated" >> .env.local
echo "SEARCH_ENGINE=elasticsearch" >> .env.local
echo "ELASTICSEARCH_DSN=http://elasticsearch:9200" >> .env.local

verbose_output ddev get ddev/ddev-elasticsearch
fi

echo "👷 Configured search engine: $SEARCH_ENGINE"

echo "✅ Finished setting up ddev services. Restarting the environment..."
touch "$PROVISION_FILE_SERVICES"
ddev restart
94 changes: 94 additions & 0 deletions .ddev/commands/web/.utils
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
#!/bin/bash

#
# Default settings
#

export PRIMARY_COLOR="#FF4713"
export GUM_SPIN_SPINNER_FOREGROUND="$PRIMARY_COLOR"
export GUM_CHOOSE_HEADER_FOREGROUND="$PRIMARY_COLOR"
export BORDER_FOREGROUND="$PRIMARY_COLOR"
export CLI_WIDTH=90
export IBEXA_DXP_INSTALLED_LOCK_FILE=".ddev/.ibexa-dxp-installed"
export INSTANCE_SETTINGS_FILE=".ddev/.ibexa-instance-settings"

#
# Helper functions
#

function bold() {
gum style --bold "$@"
}

function italic() {
gum style --italic "$@"
}

function underline() {
gum style --underline "$@"
}

function faint() {
gum style --faint "$@"
}

function choose() {
local HEADER="$1"
shift
SELECT=$(gum choose --header "$HEADER" -- "$@")
}

function execute_with_spinner() {
TITLE="$1"
shift

if [ "$VERBOSE_INSTALL" = true ]; then
"$@"
else
gum spin --title "$TITLE" --timeout 0 -- "$@"
fi
}

function banner() {
gum style \
--foreground "#FF4713" \
--align center --width 90 \
"" \
"#%%* =# " \
"%%%+ -#%% " \
"%#- #%%% " \
". . #%%% .... ... ..... ... " \
" :** #%%%:+#%%%%%%#+: -+#%%%%%#+- -#%%%*. :=*%%%%%%#+- " \
"+%%* #%%%%%%#*+++#%%%#- +%%%%#+++*%%%%+. :#%%%*: :*%%%%**+*#%%%%= " \
"%%%* #%%%%+. .=%%%* .#%%#= .+%%%*..: -#%%%+: =%%%*: .+%%%# " \
"%%%* #%%%- :%%%= *%%%. .+%%%*:.*%%*#%%%*. :%%%= :%%%+" \
"%%%* #%%% #%%* %%%+ .+%%%*: -%%%%%#: +%%% *%%%" \
"%%%* +%%%. %%%+ #%%# .+%%%*: -#%%%%%%*: =%%%. #%%%" \
"%%%* .%%%#: .#%%#. -%%%*%%%*- -#%%%*:-*%%%*: #%%#: .*%%%%" \
"%%%* :#%%%*=::.:=*%%%#. -%%%%%*:.:-+%%%%*. :*%%%*: *%%%*-:...-+%%%%%%" \
"%%%* -*%%%%%%%%%%*- .=#%%%%%%%%%#+. -#%%%*: :*%%%%%%%%%%##%%=" \
""

gum style \
--foreground "#FFFFFF" --faint --align center --width 90 \
"~==[ $1 ]==~" \
""
}

#
# Custom error handling
# ---
# Exits on all errors occurred during runtime
#

# Immediately stop the execution on error
set -e

function error_handler() {
echo ""
echo "❌️ An error occurred. Exiting..."
exit 1
}

# Set custom error handler
trap 'error_handler' ERR
4 changes: 4 additions & 0 deletions .ddev/commands/web/README.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#ddev-generated
Scripts in this directory will be executed inside the web container.

See https://ddev.readthedocs.io/en/stable/users/extend/custom-commands/#environment-variables-provided for a list of environment variables that can be used in the scripts.
10 changes: 10 additions & 0 deletions .ddev/commands/web/gum
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/bash

#ddev-generated
## Description: Run gum in the web container
## Usage: gum
## Example: "ddev gum"
## ExecRaw: true
## HostWorkingDir: true

gum "$@"
Loading