From e3ae93164bb06e3b7986792a4457f8fbf2f4888a Mon Sep 17 00:00:00 2001 From: Shinsuke Sugaya Date: Mon, 27 May 2024 08:13:28 +0900 Subject: [PATCH] fess 14.14.0 --- compose/compose.yaml | 4 +- compose/playwright/Dockerfile | 2 +- compose/snapshot/compose.yaml | 2 +- fess/14.14/Dockerfile | 33 ++++++++ fess/14.14/run.sh | 155 ++++++++++++++++++++++++++++++++++ 5 files changed, 192 insertions(+), 4 deletions(-) create mode 100644 fess/14.14/Dockerfile create mode 100755 fess/14.14/run.sh diff --git a/compose/compose.yaml b/compose/compose.yaml index 03fff93..3598fe7 100644 --- a/compose/compose.yaml +++ b/compose/compose.yaml @@ -1,12 +1,12 @@ services: fess01: - image: ghcr.io/codelibs/fess:14.13.0 + image: ghcr.io/codelibs/fess:14.14.0 # build: ./playwright # use Playwright container_name: fess01 environment: - "SEARCH_ENGINE_HTTP_URL=http://es01:9200" - "FESS_DICTIONARY_PATH=${FESS_DICTIONARY_PATH:-/usr/share/opensearch/config/dictionary/}" - # - "FESS_PLUGINS=fess-webapp-semantic-search:14.13.0 fess-ds-wikipedia:14.13.0" + # - "FESS_PLUGINS=fess-webapp-semantic-search:14.14.0 fess-ds-wikipedia:14.14.0" ports: - "8080:8080" networks: diff --git a/compose/playwright/Dockerfile b/compose/playwright/Dockerfile index a6436cf..e96292f 100644 --- a/compose/playwright/Dockerfile +++ b/compose/playwright/Dockerfile @@ -1,4 +1,4 @@ -FROM ghcr.io/codelibs/fess:14.13.0 +FROM ghcr.io/codelibs/fess:14.14.0 RUN apt-get update && \ apt-get install -y \ diff --git a/compose/snapshot/compose.yaml b/compose/snapshot/compose.yaml index 6644188..363820c 100644 --- a/compose/snapshot/compose.yaml +++ b/compose/snapshot/compose.yaml @@ -7,7 +7,7 @@ services: # - "SEARCH_ENGINE_HTTP_URL=http://es01:9200,http://es02:9200,http://es03:9200,http://es04:9200,http://es05:9200" - "SEARCH_ENGINE_HTTP_URL=http://es01:9200" - "FESS_DICTIONARY_PATH=${FESS_DICTIONARY_PATH:-/usr/share/opensearch/config/dictionary/}" - # - "FESS_PLUGINS=fess-webapp-semantic-search:14.9.0-SNAPSHOT" + # - "FESS_PLUGINS=fess-webapp-semantic-search:14.14.0-SNAPSHOT" ports: - "8080:8080" networks: diff --git a/fess/14.14/Dockerfile b/fess/14.14/Dockerfile new file mode 100644 index 0000000..f32816f --- /dev/null +++ b/fess/14.14/Dockerfile @@ -0,0 +1,33 @@ +FROM eclipse-temurin:17-jre-focal + +ENV FESS_APP_TYPE docker + +RUN apt-get update && \ + apt-get install -y imagemagick unoconv poppler-utils && \ + apt-get clean && rm -rf /var/lib/apt/lists/* + +ARG FESS_VERSION=14.14.0 + +RUN groupadd -g 1001 fess && \ + useradd -u 1001 -g fess --system --no-create-home --home /var/lib/fess fess + +ARG CACHEBUST=1 +RUN set -x && \ + curl -LfsSo /tmp/fess-${FESS_VERSION}.deb \ + https://github.com/codelibs/fess/releases/download/fess-${FESS_VERSION}/fess-${FESS_VERSION}.deb && \ + dpkg -i /tmp/fess-${FESS_VERSION}.deb && \ + rm -rf /tmp/fess-${FESS_VERSION}.deb && \ + for f in $(find /usr/share/fess/app/WEB-INF/ -type f | grep log4j2.xml) ; do sed -i 's/[^\t]*/\/>/' $f; done && \ + mkdir /opt/fess && \ + chown -R fess.fess /opt/fess && \ + sed -i -e 's#FESS_CLASSPATH="$FESS_CONF_PATH:$FESS_CLASSPATH"#FESS_CLASSPATH="$FESS_OVERRIDE_CONF_PATH:$FESS_CONF_PATH:$FESS_CLASSPATH"#g' /usr/share/fess/bin/fess && \ + echo "export FESS_APP_TYPE=$FESS_APP_TYPE" >> /usr/share/fess/bin/fess.in.sh && \ + echo "export FESS_OVERRIDE_CONF_PATH=/opt/fess" >> /usr/share/fess/bin/fess.in.sh && \ + apt-get clean && rm -rf /var/lib/apt/lists/* + +WORKDIR /usr/share/fess +EXPOSE 8080 + +USER root +COPY run.sh /usr/share/fess/run.sh +ENTRYPOINT /usr/share/fess/run.sh diff --git a/fess/14.14/run.sh b/fess/14.14/run.sh new file mode 100755 index 0000000..4dd017a --- /dev/null +++ b/fess/14.14/run.sh @@ -0,0 +1,155 @@ +#!/bin/bash + +temp_dir=/tmp +plugin_dir=/usr/share/fess/app/WEB-INF/plugin + +print_log() { + log_level=$1 + message=$2 + echo '{"@timestamp":"'$(date -u "+%Y-%m-%dT%H:%M:%S.%3NZ")'","log.level": "'${log_level}'","message":"'"${message}"'", "ecs.version": "1.2.0","service.name":"fess","event.dataset":"app","process.thread.name":"bootstrap","log.logger":"run.sh"}' +} + +if [[ "x${FESS_DICTIONARY_PATH}" != "x" ]] ; then + sed -i -e "s|^FESS_DICTIONARY_PATH=.*|FESS_DICTIONARY_PATH=${FESS_DICTIONARY_PATH}|" /etc/default/fess +fi + +if [[ "x${SEARCH_ENGINE_HTTP_URL}" != "x" ]] ; then + sed -i -e "s|^SEARCH_ENGINE_HTTP_URL=.*|SEARCH_ENGINE_HTTP_URL=${SEARCH_ENGINE_HTTP_URL}|" /etc/default/fess +elif [[ "x${ES_HTTP_URL}" != "x" ]] ; then + print_log WARN "ES_HTTP_URL is deprecated." + sed -i -e "s|^SEARCH_ENGINE_HTTP_URL=.*|SEARCH_ENGINE_HTTP_URL=${ES_HTTP_URL}|" /etc/default/fess +else + SEARCH_ENGINE_HTTP_URL=http://localhost:9200 +fi + +if [[ "x${SEARCH_ENGINE_TYPE}" != "x" ]] ; then + FESS_JAVA_OPTS="${FESS_JAVA_OPTS} -Dfess.config.search_engine.type=${SEARCH_ENGINE_TYPE}" +elif [[ "x${ES_TYPE}" != "x" ]] ; then + print_log WARN "ES_TYPE is deprecated." + FESS_JAVA_OPTS="${FESS_JAVA_OPTS} -Dfess.config.search_engine.type=${ES_TYPE}" +fi + +if [[ "x${SEARCH_ENGINE_USERNAME}" != "x" ]] ; then + FESS_JAVA_OPTS="${FESS_JAVA_OPTS} -Dfess.config.search_engine.username=${SEARCH_ENGINE_USERNAME}" +elif [[ "x${ES_USERNAME}" != "x" ]] ; then + print_log WARN "ES_USERNAME is deprecated." + FESS_JAVA_OPTS="${FESS_JAVA_OPTS} -Dfess.config.search_engine.username=${ES_USERNAME}" +fi + +if [[ "x${SEARCH_ENGINE_PASSWORD}" != "x" ]] ; then + FESS_JAVA_OPTS="${FESS_JAVA_OPTS} -Dfess.config.search_engine.password=${SEARCH_ENGINE_PASSWORD}" +elif [[ "x${ES_PASSWORD}" != "x" ]] ; then + print_log WARN "ES_PASSWORD is deprecated." + FESS_JAVA_OPTS="${FESS_JAVA_OPTS} -Dfess.config.search_engine.password=${ES_PASSWORD}" +fi + +if [[ "x${FESS_JAVA_OPTS}" != "x" ]] ; then + echo "FESS_JAVA_OPTS=\"${FESS_JAVA_OPTS}\"" >> /etc/default/fess +fi + +if [[ "x${PING_RETRIES}" = "x" ]] ; then + PING_RETRIES=3 +fi + +if [[ "x${PING_INTERVAL}" = "x" ]] ; then + PING_INTERVAL=60 +fi + +download_plugin() { + plugin_id=$1 + plugin_name=$(echo ${plugin_id} | sed -e "s/:.*//") + plugin_version=$(echo ${plugin_id} | sed -e "s/.*://") + if [[ ${plugin_name} == fess-ds-* ]] \ + || [[ ${plugin_name} == fess-ingest-* ]] \ + || [[ ${plugin_name} == fess-script-* ]] \ + || [[ ${plugin_name} == fess-theme-* ]] \ + || [[ ${plugin_name} == fess-webapp-* ]] \ + ; then + plugin_file="${plugin_name}-${plugin_version}.jar" + if [[ ${plugin_version} == *-SNAPSHOT ]] ; then + metadata_file="${temp_dir}/maven-metadata.$$" + metadata_url="https://oss.sonatype.org/content/repositories/snapshots/org/codelibs/fess/${plugin_name}/${plugin_version}/maven-metadata.xml" + if ! curl -fs -o "${metadata_file}" "${metadata_url}" ; then + print_log ERROR "Failed to download from ${metadata_url}." + return + fi + version_timestamp=$(cat ${metadata_file} | grep "" | head -n1 | sed -e "s,.*timestamp>\(.*\)" | head -n1 | sed -e "s,.*buildNumber>\(.*\) /dev/null; then + print_log ERROR "Failed to download ${plugin_file}." + return + fi + if ! curl -fs -o "${temp_dir}/${plugin_file}.sha1" "${plugin_url}.sha1" > /dev/null; then + print_log ERROR "Failed to download ${plugin_file}.sha1." + return + fi + if ! echo "$(cat "${temp_dir}/${plugin_file}.sha1") "${temp_dir}/${plugin_file}|sha1sum -c > /dev/null ; then + print_log ERROR "Invalid checksum for ${plugin_file}." + return + fi + print_log INFO "Installing ${plugin_file}" + rm -f "${temp_dir}/${plugin_file}.sha1" + mv "${temp_dir}/${plugin_file}" "${plugin_dir}" + chown fess:fess "${plugin_dir}/${plugin_file}" + fi +} + +start_fess() { + rm -f /usr/bin/java + ln -s /opt/java/openjdk/bin/java /usr/bin/java + touch /var/log/fess/fess-crawler.log \ + /var/log/fess/fess-suggest.log \ + /var/log/fess/fess-thumbnail.log \ + /var/log/fess/fess-urls.log \ + /var/log/fess/audit.log \ + /var/log/fess/fess.log + chown fess:fess /var/log/fess/fess-crawler.log \ + /var/log/fess/fess-suggest.log \ + /var/log/fess/fess-thumbnail.log \ + /var/log/fess/fess-urls.log \ + /var/log/fess/audit.log \ + /var/log/fess/fess.log + tail -qF /var/log/fess/fess-crawler.log /var/log/fess/fess-suggest.log /var/log/fess/fess-thumbnail.log /var/log/fess/fess.log /var/log/fess/audit.log 2>/dev/null & + print_log INFO "Starting Fess service." + /etc/init.d/fess start > /dev/null 2>&1 +} + +wait_app() { + if [[ "x${FESS_CONTEXT_PATH}" = "x" ]] ; then + ping_path=/api/v1/health + else + ping_path=${FESS_CONTEXT_PATH}/api/v1/health + fi + while true ; do + status=$(curl -w '%{http_code}\n' -s -o /dev/null "http://localhost:8080${ping_path}") + if [[ x"${status}" = x200 ]] ; then + error_count=0 + else + error_count=$((error_count + 1)) + fi + if [[ ${error_count} -ge ${PING_RETRIES} ]] ; then + print_log ERROR "Fess is not available." + exit 1 + fi + sleep ${PING_INTERVAL} + done +} + +for plugin_id in $FESS_PLUGINS ; do + download_plugin $(echo ${plugin_id} | sed -e "s,/,,g") +done + +start_fess + +if [[ "x${RUN_SHELL}" = "xtrue" ]] ; then + /bin/bash +else + wait_app +fi