diff --git a/.env.sample b/.env.sample index 4ff554e..910a8b7 100644 --- a/.env.sample +++ b/.env.sample @@ -6,10 +6,15 @@ APP_VERSION=latest # choose what extra services you want to run COMPOSE_FILE="compose.yml:compose.meilisearch.yml" -# Enable `compose.mail.yml` to set secrets for sending emails: + +# To use Sonic instead of Meilisearch as the search backend: +# COMPOSE_FILE="compose.yml:compose.sonic.yml" + +# Enable `compose.mail.yml` to set secrets for sending emails (remember to also include your chosen search backend's compose file): # COMPOSE_FILE="compose.yml:compose.mail.yml" -# Enable `compose.postgres.tune.yml` for Postgres tuning (recommended, but only once your instance already is deployed and working): -# COMPOSE_FILE="compose.yml:postgres/compose.postgres.tune.yml" + +# Enable `compose.postgres.tune.yml` for Postgres tuning (can only be enabled *after* your instance already is deployed and working) (and remember to also include your chosen search backend and mailer's compose files) +# COMPOSE_FILE="compose.yml:compose.postgres.tune.yml" APP_VERSION_FLAVOUR=${APP_VERSION}-${FLAVOUR} # Different flavours/forks or architectures may require different builds of bonfire: @@ -152,6 +157,7 @@ WITH_AI=0 # these secrets will be autogenerated/managed by abra and docker" SECRET_POSTGRES_PASSWORD_VERSION=v1 SECRET_MEILI_MASTER_KEY_VERSION=v1 +SECRET_SONIC_PASSWORD_VERSION=v1 SECRET_SEEDS_PW_VERSION=v1 SECRET_LIVEBOOK_PASSWORD_VERSION=v1 SECRET_MAIL_KEY_VERSION=v1 diff --git a/abra.sh b/abra.sh index 5e31be1..84e8101 100644 --- a/abra.sh +++ b/abra.sh @@ -1,4 +1,5 @@ export APP_ENTRYPOINT_VERSION=v2 export PG_BACKUP_VERSION=v4 export MEILI_BACKUP_VERSION=v4 - +export SONIC_CFG_VERSION=v1 +export SONIC_ENTRYPOINT_VERSION=v1 diff --git a/compose.sonic.yml b/compose.sonic.yml new file mode 100644 index 0000000..8fe1796 --- /dev/null +++ b/compose.sonic.yml @@ -0,0 +1,47 @@ +--- +version: "3.8" + +services: + app: + depends_on: + - search + environment: + - SEARCH_ADAPTER=sonic + - SONIC_HOST=${STACK_NAME}_search + - SONIC_PORT=1491 + - SONIC_PASSWORD_FILE=/run/secrets/sonic_password + secrets: + - sonic_password + + search: + image: valeriansaliou/sonic:v1.4.9 + secrets: + - sonic_password + volumes: + - "sonic-data:/var/lib/sonic/store" + networks: + - internal + entrypoint: ["/docker-entrypoint.sh"] + configs: + - source: sonic_cfg + target: /etc/sonic.cfg + mode: 0444 + - source: sonic_entrypoint + target: /docker-entrypoint.sh + mode: 0555 + +volumes: + sonic-data: + +configs: + sonic_cfg: + name: ${STACK_NAME}_sonic_cfg_${SONIC_CFG_VERSION} + file: sonic.cfg + sonic_entrypoint: + name: ${STACK_NAME}_sonic_entrypoint_${SONIC_ENTRYPOINT_VERSION} + file: sonic_entrypoint.sh + +secrets: + sonic_password: + external: true + name: ${STACK_NAME}_sonic_password_${SECRET_SONIC_PASSWORD_VERSION} diff --git a/sonic.cfg b/sonic.cfg new file mode 100644 index 0000000..5417d4a --- /dev/null +++ b/sonic.cfg @@ -0,0 +1,43 @@ +# Sonic configuration +# https://github.com/valeriansaliou/sonic/blob/master/CONFIGURATION.md + +[server] + log_level = "error" + +[channel] + inet = "0.0.0.0:1491" + tcp_timeout = 300 + + [channel.search] + query_limit_default = 10 + query_limit_maximum = 200 + suggest_limit_default = 5 + suggest_limit_maximum = 20 + +[store.kv] + path = "/var/lib/sonic/store/kv/" + retain_word_objects = 1000 + + [store.kv.pool] + inactive_after = 1800 + + [store.kv.database] + flush_after = 900 + compress = true + parallelism = 2 + max_files = 100 + max_compactions = 1 + max_flushes = 1 + write_buffer = 16384 + write_ahead_log = true + +[store.fst] + path = "/var/lib/sonic/store/fst/" + + [store.fst.pool] + inactive_after = 300 + + [store.fst.graph] + consolidate_after = 180 + max_size = 2048 + max_words = 250000 diff --git a/sonic_entrypoint.sh b/sonic_entrypoint.sh new file mode 100644 index 0000000..22b722f --- /dev/null +++ b/sonic_entrypoint.sh @@ -0,0 +1,5 @@ +#!/bin/sh + +export SONIC_CHANNEL__AUTH_PASSWORD="$(cat /run/secrets/sonic_password)" + +exec sonic -c /etc/sonic.cfg