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

Bring Magento template up-to-date #18

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
21 changes: 13 additions & 8 deletions .env
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,23 @@ TRAEFIK_DOMAIN=exampleproject.test
TRAEFIK_SUBDOMAIN=app

WARDEN_DB=1
WARDEN_ELASTICSEARCH=1
WARDEN_ELASTICSEARCH=0
WARDEN_OPENSEARCH=1
WARDEN_ELASTICHQ=0
WARDEN_VARNISH=1
WARDEN_RABBITMQ=1
WARDEN_REDIS=1
PHP_XDEBUG_3=1

ELASTICSEARCH_VERSION=7.6
MARIADB_VERSION=10.3
NODE_VERSION=10
PHP_VERSION=7.4
RABBITMQ_VERSION=3.8
REDIS_VERSION=5.0
VARNISH_VERSION=6.0
COMPOSER_VERSION=2.2
OPENSEARCH_VERSION=2.5
MYSQL_DISTRIBUTION=mariadb
MYSQL_DISTRIBUTION_VERSION=10.6
NODE_VERSION=12
PHP_VERSION=8.2
RABBITMQ_VERSION=3.11
REDIS_VERSION=7.0
VARNISH_VERSION=7.4

WARDEN_SYNC_IGNORE=

Expand Down
37 changes: 29 additions & 8 deletions .warden/commands/bootstrap.cmd

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will be nice if the script automatic check the .env file and identify if it set elasticsearch or opensearch as search engine.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add elasticsearch setup parameters to INSTALL_FLAGS

Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@ cd "${WARDEN_ENV_PATH}"

## configure command defaults
WARDEN_WEB_ROOT="$(echo "${WARDEN_WEB_ROOT:-/}" | sed 's#^/#./#')"
REQUIRED_FILES=("${WARDEN_WEB_ROOT}/auth.json")
REQUIRED_FILES=()
DB_DUMP="${DB_DUMP:-./backfill/magento-db.sql.gz}"
DB_IMPORT=1
CLEAN_INSTALL=
AUTO_PULL=1
META_PACKAGE="magento/project-community-edition"
META_VERSION=""
URL_FRONT="https://${TRAEFIK_SUBDOMAIN}.${TRAEFIK_DOMAIN}/"
URL_ADMIN="https://${TRAEFIK_SUBDOMAIN}.${TRAEFIK_DOMAIN}/backend/"
URL_ADMIN="https://${TRAEFIK_SUBDOMAIN}.${TRAEFIK_DOMAIN}/admin/"
navarr marked this conversation as resolved.
Show resolved Hide resolved

## argument parsing
## parse arguments
Expand Down Expand Up @@ -161,19 +161,40 @@ else
fi
warden env up -d

# If neither global nor local exists, prompt for creds
if [[ ! -f "${WARDEN_WEB_ROOT}/auth.json" ]]; then
# Prompt for creds
read -p "No existing composer credentials were found. Would you like to configure them? [y/N] " willManuallyInputCreds
if [[ "$willManuallyInputCreds" =~ ^([yY][eE][sS]|[yY1])$ ]]; then
read -p "Public Key: " composerPublicKey
read -p "Private Key: " composerPrivateKey

hadToCreateComposerJson=0
if [[ ! -f "${WARDEN_WEB_ROOT}/composer.json" ]]; then
hadToCreateComposerJson=1
# Temporary workaround for auth requiring composer.json file
echo "{}" > "${WARDEN_WEB_ROOT}/composer.json"
sleep 1 # Give a second to sync
fi
warden env exec -T php-fpm composer config http-basic.repo.magento.com "$composerPublicKey" "$composerPrivateKey"
if [[ ${hadToCreateComposerJson} == 1 ]]; then
rm ${WARDEN_WEB_ROOT}/composer.json
sleep 1 # Give a second to sync
fi
fi
fi

## wait for mariadb to start listening for connections
warden shell -c "while ! nc -z db 3306 </dev/null; do sleep 2; done"

if [[ ${CLEAN_INSTALL} ]] && [[ ! -f "${WARDEN_WEB_ROOT}/composer.json" ]]; then
:: Installing meta-package
warden env exec -T php-fpm composer create-project -q --no-interaction --prefer-dist --no-install \
--repository-url=https://repo.magento.com/ "${META_PACKAGE}" /tmp/create-project "${META_VERSION}"
# Was having a weird issue here where auth.json just would not work, kept getting 404. COMPOSER_AUTH export is workaround
warden env exec -T php-fpm /bin/bash -c "export COMPOSER_AUTH=\"\$(cat auth.json)\" && composer create-project -q --no-interaction --prefer-dist --no-install --repository=https://repo.magento.com/ \"${META_PACKAGE}\" /tmp/create-project \"${META_VERSION}\""
warden env exec -T php-fpm rsync -a /tmp/create-project/ /var/www/html/
fi

:: Installing dependencies
warden env exec -T php-fpm bash \
-c '[[ $(composer -V | cut -d\ -f3 | cut -d. -f1) == 2 ]] || composer global require hirak/prestissimo'
warden env exec -T php-fpm composer install

## import database only if --skip-db-import is not specified
Expand Down Expand Up @@ -218,7 +239,7 @@ elif [[ ${CLEAN_INSTALL} ]]; then

INSTALL_FLAGS="${INSTALL_FLAGS} \
--cleanup-database \
--backend-frontname=backend \
--backend-frontname=admin \
--db-host=db \
--db-name=magento \
--db-user=magento \
Expand Down Expand Up @@ -278,7 +299,7 @@ OTPAUTH_QRI=
if test $(version $(warden env exec -T php-fpm bin/magento -V | awk '{print $3}')) -ge $(version 2.4.0); then
TFA_SECRET=$(warden env exec -T php-fpm pwgen -A1 128)
TFA_SECRET=$(
warden env exec -T php-fpm python -c "import base64; print base64.b32encode('${TFA_SECRET}')" | sed 's/=*$//'
warden env exec -T php-fpm python3 -c "import base64; print(base64.b32encode(bytearray('${TFA_SECRET}', 'ascii')).decode('utf-8'))" | sed 's/=*$//'
)
OTPAUTH_URL=$(printf "otpauth://totp/%s%%3Alocaladmin%%40example.com?issuer=%s&secret=%s" \
"${TRAEFIK_SUBDOMAIN}.${TRAEFIK_DOMAIN}" "${TRAEFIK_SUBDOMAIN}.${TRAEFIK_DOMAIN}" "${TFA_SECRET}"
Expand Down