Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/integrationTest/resources/docker-compose-solr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ services:
- GLOBAL_WORKSPACE_solr.suggester.minSecsBetweenBuilds=3
- LOG_log4j.logger.org.alfresco.solr.tracker.MetadataTracker=DEBUG
- LOG_log4j.appender.file.MaxFileSize=8MB
# - JAVA_OPTS_MEMORY_TRACKING=-XX:+UseContainerSupport -Xlog:os+container=debug -XX:InitialRAMPercentage=50 -XX:MaxRAMPercentage=50 -Xss512k -XX:MaxMetaspaceSize=256M -XX:CompressedClassSpaceSize=32M -XX:ProfiledCodeHeapSize=128M -XX:NonProfiledCodeHeapSize=128M -XX:NonNMethodCodeHeapSize=32M -XX:ReservedCodeCacheSize=288M -XX:MaxDirectMemorySize=64m
# for restoring from backup, uncomment following variables
# - JAVA_OPTS_S3_ENDPOINT=-DS3_ENDPOINT=<endpoint_s3_protocol>
# - JAVA_OPTS_S3_REGION=-DS3_REGION=<bucket_s3_region>
Expand Down
7 changes: 4 additions & 3 deletions src/main/resources/dockerfiles/Dockerfile.solr6
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
ARG BASE_IMAGE=docker.io/xenit/openjdk:alfresco-6.1-ubuntu
ARG BASE_IMAGE=eclipse-temurin:11.0.27_6-jdk-focal
FROM alpine:latest AS build-stage-solr6

ARG SOLR_VERSION_MAJOR
Expand Down Expand Up @@ -58,7 +58,8 @@ RUN apt-get update && \
&& touch ${SOLR_INSTALL_HOME}/healthcheck.sh \
&& chmod +x ${SOLR_INSTALL_HOME}/healthcheck.sh

COPY 91-healthcheck.sh 92-init-solr.sh /docker-entrypoint.d/
COPY 80-java-opts.sh 89-check-validity.sh 91-healthcheck.sh 92-init-solr.sh /docker-entrypoint.d/
COPY docker-entrypoint.sh /docker-entrypoint.sh

# add the keystore
ADD keystore ${SOLR_INSTALL_HOME}/solrhome/keystore
Expand All @@ -69,5 +70,5 @@ WORKDIR ${SOLR_INSTALL_HOME}

HEALTHCHECK --interval=30s --timeout=3s --retries=3 --start-period=20s CMD ${SOLR_INSTALL_HOME}/healthcheck.sh || exit 1

CMD ["${SOLR_INSTALL_HOME}/startup.sh"]
CMD ["/bin/bash", "-c", "/docker-entrypoint.sh && ./startup.sh"]

46 changes: 46 additions & 0 deletions upstream/solr6/local/80-java-opts.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
#!/bin/bash

if [[ $JMX_ENABLED == true ]]
then
JMX_RMI_HOST=${JMX_RMI_HOST:-'0.0.0.0'}
JAVA_OPTS_JMX="-Dcom.sun.management.jmxremote.authenticate=false \
-Dcom.sun.management.jmxremote.local.only=false \
-Dcom.sun.management.jmxremote.ssl=false \
-Dcom.sun.management.jmxremote \
-Dcom.sun.management.jmxremote.rmi.port=5000 \
-Dcom.sun.management.jmxremote.port=5000 \
-Djava.rmi.server.hostname=${JMX_RMI_HOST}"
export JAVA_OPTS_JMX
fi

if [[ $DEBUG == true ]]
then
JAVA_OPTS_DEBUG="-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=0.0.0.0:8000"
export JAVA_OPTS_DEBUG
fi

if [[ -n $JAVA_XMX ]]
then
JAVA_OPTS_XMX="-Xmx${JAVA_XMX}"
export JAVA_OPTS_XMX
fi

if [[ -n $JAVA_XMS ]]
then
JAVA_OPTS_XMS="-Xms${JAVA_XMS}"
export JAVA_OPTS_XMS
fi

IFS=$'\n'
for I in $(env); do
if [[ $I == JAVA_OPTS_* ]]; then
echo "-- collecting $I"
VALUE=$(echo $I | cut -d '=' -f 2-)
JAVA_OPTS="$JAVA_OPTS $VALUE"
fi
done

# Trim leading/trailing whitespace
export JAVA_OPTS=$(echo $JAVA_OPTS | xargs echo)

echo "Result: JAVA_OPTS=${JAVA_OPTS}"
17 changes: 17 additions & 0 deletions upstream/solr6/local/89-check-validity.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/bin/bash

currentDate=`date +%s`
if [ -z "${BUILD_DATE}" ]
then
1>&2 echo "$(tput -Txterm setaf 3)****************************************************$(tput -Txterm sgr0)"
1>&2 echo "$(tput -Txterm setaf 3)Unable to determine image age: BUILD_DATE is not set$(tput -Txterm sgr0)"
1>&2 echo "$(tput -Txterm setaf 3)****************************************************$(tput -Txterm sgr0)"
else
timeelapsed=`expr ${currentDate} - ${BUILD_DATE}`
if [ $timeelapsed -ge 2592000 ] # 30 days
then
1>&2 echo "$(tput -Txterm setaf 3)****************************************************************************************$(tput -Txterm sgr0)"
1>&2 echo "$(tput -Txterm setaf 3)This is an old image: BUILD_DATE=$(date -d @$BUILD_DATE +"%Y-%m-%d %H:%M:%S") and currentDate=$(date -d @$currentDate +"%Y-%m-%d %H:%M:%S")$(tput -Txterm sgr0)"
1>&2 echo "$(tput -Txterm setaf 3)****************************************************************************************$(tput -Txterm sgr0)"
fi
fi
24 changes: 18 additions & 6 deletions upstream/solr6/local/92-init-solr.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,6 @@ TEMPLATE=${TEMPLATE:-'rerank'}
ALFRESCO_SOLR_SUGGESTER_ENABLED=${ALFRESCO_SOLR_SUGGESTER_ENABLED:-'true'}
ALFRESCO_SOLR_FACETABLE_CATEGORIES_ENABLED=${ALFRESCO_SOLR_FACETABLE_CATEGORIES_ENABLED:-'false'}

JAVA_XMS=${JAVA_XMS:-'512M'}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This property does not seem to be used?

JAVA_XMX=${JAVA_XMX:-'2048M'}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wait to low for Solr anyway. Drop it + give a warning.


CONFIG_FILE_SOLR_START="$SOLR_INSTALL_HOME/solr.in.sh"

CUSTOM_SCHEMA=${CUSTOM_SCHEMA:-'false'}
Expand All @@ -39,6 +36,11 @@ function setJavaOption {
}

function setOption {
if [[ -z "$3" ]]; then
echo "setOption failed (parameters: $1, $2, $3)"
exit 1
fi

if grep --quiet -e "$1\s*=" "$3"; then
# replace option
sed -i "s#^\s*\($1\s*=\s*\).*\$#\1$2#" $3
Expand All @@ -64,8 +66,12 @@ function setGlobalOptions {
envCoreName=$(echo $i | cut -d '=' -f 1 | cut -d '_' -f 2)
if [[ $envCoreName = $coreName ]] || [[ $envCoreName = "ALL" ]] || [[ $envCoreName = "WORKSPACE" && $coreName =~ alfresco ]]; then
key=$(echo $i | cut -d '=' -f 1 | cut -d '_' -f 3-)
value=$(echo $i | cut -d '=' -f 2-)
setOption $key $value "$file"
if [[ -z "$key" ]]; then
echo "Skipping env. variable ($i), since the resulting key is empty."
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Example: 2025-09-11T13:42:23.976221557Z Skipping env. variable (LC_ALL=en_US.UTF-8), since the resulting key is empty.

Because this initialization script thinks that LC is a property that should be applied to ALL cores.

else
value=$(echo $i | cut -d '=' -f 2-)
setOption $key $value "$file"
fi
fi
done
}
Expand Down Expand Up @@ -277,6 +283,12 @@ fi
# fix permissions for config folders
chown -R "$user":"$user" "${SOLR_DIR_ROOT}"

echo "exec gosu ${user} ${SOLR_INSTALL_HOME}/solr/bin/solr start -f -m ${JAVA_XMX} -p ${PORT} -h ${SOLR_HOST} -s ${SOLR_DIR_ROOT} -a \"${JAVA_OPTS}\"" >"${SOLR_INSTALL_HOME}/startup.sh"
if [[ -n ${JAVA_XMX} ]]; then
echo "Found the (JAVA_XMX) environment variable; falling back to the default Solr bootup command."
echo "exec gosu ${user} ${SOLR_INSTALL_HOME}/solr/bin/solr start -f -m ${JAVA_XMX} -p ${PORT} -h ${SOLR_HOST} -s ${SOLR_DIR_ROOT} -a \"${JAVA_OPTS}\"" >"${SOLR_INSTALL_HOME}/startup.sh"
else
echo "Could not find the (JAVA_XMX) environment variable; falling back to the Solr bootup command without -m parameter. Make sure to specify the memory settings via JAVA_OPTS."
echo "exec gosu ${user} ${SOLR_INSTALL_HOME}/solr/bin/solr start -f -p ${PORT} -h ${SOLR_HOST} -s ${SOLR_DIR_ROOT} -a \"${JAVA_OPTS}\"" >"${SOLR_INSTALL_HOME}/startup.sh"
fi

echo "Solr init done"
23 changes: 23 additions & 0 deletions upstream/solr6/local/docker-entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/bin/bash

DIR=/docker-entrypoint.d

BOLD="\033[1m"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This might not work in K8S, but this gives a nice representation of what the container is actually doing locally.

RESET="\033[0m"
BLUE="\033[34m"

echo -e "${BOLD}Running all initialization scripts in ${DIR}..."
if [ -d "${DIR}" ]; then
for f in ${DIR}/*; do
case "$f" in
*.sh) echo -e "${RESET}${BOLD}$0: running $f${BLUE}"; . "$f" ;;
*) echo -e "${RESET}${BOLD}$0: ignoring $f${BLUE}" ;;
esac
echo
done
echo -e "${RESET}${BOLD}$0: done running all initialization scripts in ${DIR}."
else
echo -e "${BOLD}$0: ${DIR} does not exist, skipping initialization scripts."
fi

echo -e "Starting Solr...${RESET}"
Loading