mirror of
https://github.com/alexbelgium/hassio-addons.git
synced 2026-01-09 09:21:03 +01:00
Fix Meilisearch packaging
This commit is contained in:
@@ -1,3 +1,8 @@
|
||||
## v5.0_beta6 (06-01-2025)
|
||||
- Bundled an internal Meilisearch service and configure Monica to use it for full-text search by default.
|
||||
- Ensure the init script only launches the bundled Meilisearch when `MEILISEARCH_URL` points to localhost and wait for the health endpoint before starting Monica.
|
||||
- Unpack the bundled Meilisearch release for the detected architecture so the watchdog can start the binary successfully.
|
||||
|
||||
## v5.0_beta5 (14-11-2025)
|
||||
- Added support for configuring extra environment variables via the `env_vars` add-on option alongside config.yaml. See https://github.com/alexbelgium/hassio-addons/wiki/Add-Environment-variables-to-your-Addon-2 for details.
|
||||
|
||||
|
||||
@@ -50,6 +50,33 @@ RUN chmod 744 /ha_automodules.sh && /ha_automodules.sh "$MODULES" && rm /ha_auto
|
||||
# Manual apps
|
||||
ENV PACKAGES="mariadb-client"
|
||||
|
||||
# Meilisearch
|
||||
ARG MEILISEARCH_VERSION="v1.25.0"
|
||||
RUN set -eux && \
|
||||
DETECTED_ARCH="${BUILD_ARCH:-$(uname -m)}" && \
|
||||
case "${DETECTED_ARCH}" in \
|
||||
amd64|x86_64) MEILI_ARCH="linux-amd64" ;; \
|
||||
aarch64|arm64) MEILI_ARCH="linux-aarch64" ;; \
|
||||
*) echo "Unsupported architecture: ${DETECTED_ARCH}" >&2 && exit 1 ;; \
|
||||
esac && \
|
||||
TMP_DIR="$(mktemp -d)" && \
|
||||
BASE_URL="https://github.com/meilisearch/meilisearch/releases/download/${MEILISEARCH_VERSION}" && \
|
||||
if curl -fsSL -o "${TMP_DIR}/meilisearch.tar.gz" "${BASE_URL}/meilisearch-${MEILI_ARCH}.tar.gz"; then \
|
||||
tar -xzf "${TMP_DIR}/meilisearch.tar.gz" -C "${TMP_DIR}" && \
|
||||
MEILI_BIN="$(find "${TMP_DIR}" -maxdepth 1 -type f -name 'meilisearch' -print -quit)" && \
|
||||
if [ -z "${MEILI_BIN}" ]; then \
|
||||
echo "Unable to locate Meilisearch binary in archive" >&2; \
|
||||
exit 1; \
|
||||
fi && \
|
||||
mv "${MEILI_BIN}" /usr/local/bin/meilisearch; \
|
||||
else \
|
||||
curl -fsSL -o "${TMP_DIR}/meilisearch" "${BASE_URL}/meilisearch-${MEILI_ARCH}" && \
|
||||
mv "${TMP_DIR}/meilisearch" /usr/local/bin/meilisearch; \
|
||||
fi && \
|
||||
chmod 755 /usr/local/bin/meilisearch && \
|
||||
rm -rf "${TMP_DIR}" && \
|
||||
mkdir -p /data/meilisearch
|
||||
|
||||
# Automatic apps & bashio
|
||||
ADD "https://raw.githubusercontent.com/alexbelgium/hassio-addons/master/.templates/ha_autoapps.sh" "/ha_autoapps.sh"
|
||||
RUN chmod 744 /ha_autoapps.sh && /ha_autoapps.sh "$PACKAGES" && rm /ha_autoapps.sh
|
||||
|
||||
@@ -34,6 +34,7 @@ Key features:
|
||||
- Journal functionality
|
||||
- Gift ideas tracking
|
||||
- Multiple database options (SQLite, MariaDB, MySQL)
|
||||
- Built-in Meilisearch full-text search engine
|
||||
|
||||
This addon is based on the official [Monica](https://github.com/monicahq/monica) application.
|
||||
|
||||
@@ -104,6 +105,7 @@ Configure SMTP settings to enable:
|
||||
|
||||
This addon supports custom scripts and environment variables through the `addon_config` mapping:
|
||||
|
||||
- **Meilisearch full-text search**: The addon ships with an embedded [Meilisearch](https://www.meilisearch.com/) service that Monica uses by default. The search API listens on `http://127.0.0.1:7700` inside the container. Override `MEILISEARCH_URL` via `env_vars` if you prefer an external Meilisearch instance—the init script will detect that and skip starting the bundled daemon. You can further tweak Meilisearch by defining extra environment variables through the `env_vars` option if needed.
|
||||
- **Custom scripts**: See [Running Custom Scripts in Addons](https://github.com/alexbelgium/hassio-addons/wiki/Running-custom-scripts-in-Addons)
|
||||
- **env_vars option**: Use the add-on `env_vars` option to pass extra environment variables (uppercase or lowercase names). See https://github.com/alexbelgium/hassio-addons/wiki/Add-Environment-variables-to-your-Addon-2 for details.
|
||||
|
||||
@@ -136,5 +138,3 @@ Create an issue on github, or ask on the [home assistant community forum](https:
|
||||
For more information about Monica, visit: https://www.monicahq.com/
|
||||
|
||||
[repository]: https://github.com/alexbelgium/hassio-addons
|
||||
|
||||
|
||||
|
||||
@@ -67,6 +67,10 @@ environment:
|
||||
MAIL_MAILER: log
|
||||
DEFAULT_STORAGE_LIMIT: "1024"
|
||||
DEFAULT_MAX_STORAGE_SIZE: "1024"
|
||||
SCOUT_DRIVER: meilisearch
|
||||
SCOUT_QUEUE: "false"
|
||||
MEILISEARCH_URL: http://127.0.0.1:7700
|
||||
MEILISEARCH_KEY: ""
|
||||
image: ghcr.io/alexbelgium/monica-{arch}
|
||||
init: false
|
||||
options:
|
||||
@@ -103,5 +107,5 @@ services:
|
||||
- mysql:want
|
||||
slug: monica
|
||||
url: https://github.com/alexbelgium/hassio-addons/tree/master/monica
|
||||
version: v5.0_beta5
|
||||
version: v5.0_beta6
|
||||
webui: "[PROTO:ssl]://[HOST]:[PORT:80]"
|
||||
|
||||
@@ -113,6 +113,93 @@ fi
|
||||
APP_KEY="$(bashio::config "APP_KEY")"
|
||||
export APP_KEY
|
||||
|
||||
bashio::log.info "Preparing Meilisearch"
|
||||
MEILISEARCH_URL="${MEILISEARCH_URL:-http://127.0.0.1:7700}"
|
||||
export MEILISEARCH_URL
|
||||
|
||||
MEILISEARCH_URI="${MEILISEARCH_URL#*://}"
|
||||
MEILISEARCH_HOST_PORT="${MEILISEARCH_URI%%/*}"
|
||||
MEILISEARCH_HOST="${MEILISEARCH_HOST_PORT%%:*}"
|
||||
MEILISEARCH_PORT="${MEILISEARCH_HOST_PORT##*:}"
|
||||
if [ "${MEILISEARCH_PORT}" = "${MEILISEARCH_HOST_PORT}" ]; then
|
||||
MEILISEARCH_PORT=""
|
||||
fi
|
||||
|
||||
MEILISEARCH_LOCAL=false
|
||||
if [[ -n "${MEILISEARCH_PORT}" && ! ${MEILISEARCH_PORT} =~ ^[0-9]+$ ]]; then
|
||||
bashio::log.warning "Ignoring bundled Meilisearch because MEILISEARCH_URL uses a non-numeric port (${MEILISEARCH_PORT})."
|
||||
elif [[ "${MEILISEARCH_HOST}" =~ ^(127\.0\.0\.1|localhost)$ ]]; then
|
||||
MEILISEARCH_LOCAL=true
|
||||
if [ -z "${MEILISEARCH_PORT}" ]; then
|
||||
MEILISEARCH_PORT="7700"
|
||||
fi
|
||||
MEILISEARCH_ADDR="${MEILISEARCH_HOST}:${MEILISEARCH_PORT}"
|
||||
else
|
||||
MEILISEARCH_ADDR="127.0.0.1:7700"
|
||||
fi
|
||||
|
||||
if [[ "${MEILISEARCH_LOCAL}" == true ]]; then
|
||||
bashio::log.info "Starting bundled Meilisearch instance at ${MEILISEARCH_ADDR}"
|
||||
MEILISEARCH_DB_PATH="/data/meilisearch"
|
||||
mkdir -p "${MEILISEARCH_DB_PATH}"
|
||||
|
||||
MEILISEARCH_ENV_KEY="${MEILISEARCH_KEY:-}"
|
||||
MEILISEARCH_ENVIRONMENT="${MEILI_ENV:-production}"
|
||||
MEILISEARCH_NO_ANALYTICS="${MEILI_NO_ANALYTICS:-true}"
|
||||
|
||||
S6_SUPERVISED_DIR="/run/s6/services"
|
||||
if [ ! -d "${S6_SUPERVISED_DIR}" ]; then
|
||||
S6_SUPERVISED_DIR="/var/run/s6/services"
|
||||
fi
|
||||
|
||||
MEILISEARCH_CMD=(
|
||||
env \
|
||||
MEILI_ENV="${MEILISEARCH_ENVIRONMENT}" \
|
||||
MEILI_NO_ANALYTICS="${MEILISEARCH_NO_ANALYTICS}" \
|
||||
meilisearch \
|
||||
--http-addr "${MEILISEARCH_ADDR}" \
|
||||
--db-path "${MEILISEARCH_DB_PATH}"
|
||||
)
|
||||
|
||||
if [ -n "${MEILISEARCH_ENV_KEY}" ]; then
|
||||
MEILISEARCH_CMD+=(--master-key "${MEILISEARCH_ENV_KEY}")
|
||||
fi
|
||||
|
||||
"${MEILISEARCH_CMD[@]}" &
|
||||
MEILISEARCH_PID=$!
|
||||
|
||||
(
|
||||
set +e
|
||||
wait "${MEILISEARCH_PID}"
|
||||
exit_code=$?
|
||||
set -e
|
||||
if [ "${exit_code}" -ne 0 ]; then
|
||||
bashio::log.error "Meilisearch exited unexpectedly (code ${exit_code}). Stopping add-on."
|
||||
s6-svscanctl -t "${S6_SUPERVISED_DIR}"
|
||||
fi
|
||||
) &
|
||||
|
||||
bashio::log.info "Waiting for Meilisearch TCP socket"
|
||||
bashio::net.wait_for "${MEILISEARCH_ADDR%:*}" "${MEILISEARCH_ADDR#*:}"
|
||||
|
||||
bashio::log.info "Waiting for Meilisearch health endpoint"
|
||||
MEILISEARCH_HEALTH_URL="${MEILISEARCH_URL%/}/health"
|
||||
for attempt in $(seq 1 30); do
|
||||
if curl -fs "${MEILISEARCH_HEALTH_URL}" | grep -q '"status":"available"'; then
|
||||
bashio::log.info "Meilisearch is ready"
|
||||
break
|
||||
fi
|
||||
sleep 1
|
||||
if [ "${attempt}" -eq 30 ]; then
|
||||
bashio::log.error "Meilisearch did not become ready in time. Stopping add-on."
|
||||
s6-svscanctl -t "${S6_SUPERVISED_DIR}"
|
||||
exit 1
|
||||
fi
|
||||
done
|
||||
else
|
||||
bashio::log.info "Detected external Meilisearch endpoint (${MEILISEARCH_URL}); skipping bundled service startup"
|
||||
fi
|
||||
|
||||
bashio::log.info "Starting Monica"
|
||||
|
||||
entrypoint.sh apache2-foreground
|
||||
|
||||
Reference in New Issue
Block a user