Skip to content

Commit

Permalink
Fix Magento 2 steps if not using elasticsearch (#448)
Browse files Browse the repository at this point in the history
  • Loading branch information
kierenevans authored Oct 8, 2020
1 parent e6b50c6 commit 3a95df1
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
1 change: 1 addition & 0 deletions src/_base/harness/attributes/docker-base.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ attributes:
publish: true
environment:
DB_ADMIN_USER: root
HAS_ELASTICSEARCH: "= ('elasticsearch' in @('app.services') ? 'true' : 'false')"
HAS_VARNISH: "= ('varnish' in @('app.services') ? 'true' : 'false')"
environment_secrets:
DB_ADMIN_PASS: = @('database.root_pass')
Expand Down
2 changes: 2 additions & 0 deletions src/magento2/application/overlay/app/etc/env.php.twig
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,11 @@ return [
'default' => [
'catalog' => [
'search' => [
{% if 'elasticsearch' in @('app.services') -%}
'engine' => 'elasticsearch7',
'elasticsearch7_server_hostname' => getenv('ELASTICSEARCH_HOST')?:'elasticsearch',
'elasticsearch7_server_port' => getenv('ELASTICSEARCH_PORT')?:'9200'
{% endif -%}
],
],
],
Expand Down
15 changes: 12 additions & 3 deletions src/magento2/harness.yml
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,10 @@ attributes:
# restore it after installation.
- run rm -f /app/app/etc/env.php
- run rm -f /app/app/etc/config.php
- task http:wait "${ELASTICSEARCH_HOST}:${ELASTICSEARCH_PORT}"
- |
if [[ "$HAS_ELASTICSEARCH" == "true" ]]; then
task http:wait "${ELASTICSEARCH_HOST}:${ELASTICSEARCH_PORT}"
fi
- |
passthru "magento setup:install \
--key='${MAGENTO_CRYPT_KEY}' \
Expand Down Expand Up @@ -136,7 +139,10 @@ attributes:
init:
steps:
- task rabbitmq:vhosts
- task http:wait "${ELASTICSEARCH_HOST}:${ELASTICSEARCH_PORT}"
- |
if [[ "$HAS_ELASTICSEARCH" == "true" ]]; then
task http:wait "${ELASTICSEARCH_HOST}:${ELASTICSEARCH_PORT}"
fi
- run magento setup:upgrade --keep-generated
- run magento config:set 'web/unsecure/base_url' "https://${APP_HOST}/"
- run magento config:set 'web/secure/base_url' "https://${APP_HOST}/"
Expand All @@ -148,7 +154,10 @@ attributes:
fi
migrate:
steps:
- task http:wait "${ELASTICSEARCH_HOST}:${ELASTICSEARCH_PORT}"
- |
if [[ "$HAS_ELASTICSEARCH" == "true" ]]; then
task http:wait "${ELASTICSEARCH_HOST}:${ELASTICSEARCH_PORT}"
fi
- run magento setup:upgrade --keep-generated
- run magento cache:clean
cron:
Expand Down

0 comments on commit 3a95df1

Please sign in to comment.