diff --git a/README.md b/README.md index abba102..8d26cef 100644 --- a/README.md +++ b/README.md @@ -40,6 +40,12 @@ Like this, you can add your `docker-compose.prod.yml` to a branch of your Git re * RANCHER_URL=http://RANCHER_HOST:8080 rancher-compose --env-file=.env up +## Running without Elasticsearch + +Elasticsearch is an optional, but strongly recommended dependency for Zammad. More details can be found in the [documentation](https://docs.zammad.org/en/latest/prerequisites/software.html#elasticsearch-optional). There are however certain scenarios when running without Elasticsearch may be desired, e.g. for very small teams, for teams with limited budget or as a temporary solution for an unplanned Elasticsearch downtime or planned cluster upgrade. + +Elasticsearch is enabled by default in the example `docker-compose.yml` file. It is also by default required to run the "zammad-init" command. Disabling Elasticsearch is possible by setting a special environment variable: `ELASTICSEARCH_ENABLED=false` for the `zammad-init` container and removing all references to Elasticsearch everywhere else: the `zammad-elasticsearch` container, it's volume and links to it. + ## Upgrading ### From =< 3.3.0-12 diff --git a/containers/zammad/docker-entrypoint.sh b/containers/zammad/docker-entrypoint.sh index 694d711..d33cca5 100755 --- a/containers/zammad/docker-entrypoint.sh +++ b/containers/zammad/docker-entrypoint.sh @@ -3,6 +3,7 @@ set -e : "${AUTOWIZARD_JSON:=''}" +: "${ELASTICSEARCH_ENABLED:=true}" : "${ELASTICSEARCH_HOST:=zammad-elasticsearch}" : "${ELASTICSEARCH_PORT:=9200}" : "${ELASTICSEARCH_SCHEMA:=http}" @@ -74,32 +75,36 @@ if [ "$1" = 'zammad-init' ]; then else bundle exec rake db:migrate fi - + # es config echo "changing settings..." - bundle exec rails r "Setting.set('es_url', '${ELASTICSEARCH_SCHEMA}://${ELASTICSEARCH_HOST}:${ELASTICSEARCH_PORT}')" - - bundle exec rails r "Setting.set('es_index', '${ELASTICSEARCH_NAMESPACE}')" - - if [ -n "${ELASTICSEARCH_USER}" ] && [ -n "${ELASTICSEARCH_PASS}" ]; then - bundle exec rails r "Setting.set('es_user', \"${ELASTICSEARCH_USER}\")" - bundle exec rails r "Setting.set('es_password', \"${ELASTICSEARCH_PASS}\")" - fi - - until (echo > /dev/tcp/${ELASTICSEARCH_HOST}/${ELASTICSEARCH_PORT}) &> /dev/null; do - echo "zammad railsserver waiting for elasticsearch server to be ready..." - sleep 5 - done - - if [ "${ELASTICSEARCH_SSL_VERIFY}" == "false" ]; then - SSL_SKIP_VERIFY="-k" + if [ "${ELASTICSEARCH_ENABLED}" == "false" ]; then + bundle exec rails r "Setting.set('es_url', '')" else - SSL_SKIP_VERIFY="" - fi - - if ! curl -s ${SSL_SKIP_VERIFY} ${ELASTICSEARCH_SCHEMA}://${ELASTICSEARCH_HOST}:${ELASTICSEARCH_PORT}/_cat/indices | grep -q zammad; then - echo "rebuilding es searchindex..." - bundle exec rake searchindex:rebuild + bundle exec rails r "Setting.set('es_url', '${ELASTICSEARCH_SCHEMA}://${ELASTICSEARCH_HOST}:${ELASTICSEARCH_PORT}')" + + bundle exec rails r "Setting.set('es_index', '${ELASTICSEARCH_NAMESPACE}')" + + if [ -n "${ELASTICSEARCH_USER}" ] && [ -n "${ELASTICSEARCH_PASS}" ]; then + bundle exec rails r "Setting.set('es_user', \"${ELASTICSEARCH_USER}\")" + bundle exec rails r "Setting.set('es_password', \"${ELASTICSEARCH_PASS}\")" + fi + + until (echo > /dev/tcp/${ELASTICSEARCH_HOST}/${ELASTICSEARCH_PORT}) &> /dev/null; do + echo "zammad railsserver waiting for elasticsearch server to be ready..." + sleep 5 + done + + if [ "${ELASTICSEARCH_SSL_VERIFY}" == "false" ]; then + SSL_SKIP_VERIFY="-k" + else + SSL_SKIP_VERIFY="" + fi + + if ! curl -s ${SSL_SKIP_VERIFY} ${ELASTICSEARCH_SCHEMA}://${ELASTICSEARCH_HOST}:${ELASTICSEARCH_PORT}/_cat/indices | grep -q zammad; then + echo "rebuilding es searchindex..." + bundle exec rake searchindex:rebuild + fi fi # chown everything to zammad user