Enable installation of custom libs/jars/extensions

pull/1/head
Nils Bühner 2020-12-17 20:12:44 +01:00
parent a4e3a83816
commit 4261b1bdc1
4 changed files with 40 additions and 20 deletions

View File

@ -15,11 +15,11 @@ ENV GS_VERSION=${GS_VERSION} \
DOWNLOAD_EXTENSIONS=false \ DOWNLOAD_EXTENSIONS=false \
STABLE_EXTENSIONS='' \ STABLE_EXTENSIONS='' \
DEBIAN_FRONTEND=noninteractive \ DEBIAN_FRONTEND=noninteractive \
EXTENSION_DOWNLOAD_DIR=/opt/geoserver_extension_downloads \ ADDITIONAL_LIBS_DIR=/opt/additional_libs/ \
GEOSERVER_DATA_DIR=/opt/geoserver_data \ GEOSERVER_DATA_DIR=/opt/geoserver_data/ \
GEOWEBCACHE_CACHE_DIR=/opt/geowebcache_data GEOWEBCACHE_CACHE_DIR=/opt/geowebcache_data/
RUN mkdir ${EXTENSION_DOWNLOAD_DIR} ${GEOSERVER_DATA_DIR} ${GEOWEBCACHE_CACHE_DIR} RUN mkdir ${ADDITIONAL_LIBS_DIR} ${GEOSERVER_DATA_DIR} ${GEOWEBCACHE_CACHE_DIR}
# install required dependencies # install required dependencies
# also clear the initial webapps # also clear the initial webapps

View File

@ -31,7 +31,7 @@ You can quickstart by using the docker-compose demo
## Running ## Running
`docker run -it -e STABLE_EXTENSIONS='wps,csw' -p 8080:8080 geoserver:test` `docker run -it -e DOWNLOAD_EXTENSIONS='true' -e STABLE_EXTENSIONS='wps,csw' -p 8080:8080 geoserver:test`
The extensions will be downloaded on startup of the image (before starting the tomcat). The extensions will be downloaded on startup of the image (before starting the tomcat).
@ -44,16 +44,13 @@ Pass as environment variables. If not passed, the default values will be used.
* `MAXIMUM_MEMORY` (default: 4G) * `MAXIMUM_MEMORY` (default: 4G)
* `JAIEXT_ENABLED` (default: true) * `JAIEXT_ENABLED` (default: true)
* `DOWNLOAD_EXTENSIONS` (default: false) * `DOWNLOAD_EXTENSIONS` (default: false)
* `STABLE_EXTENSIONS` as comma separated list, will be downloaded and installed on startup (default: "") * `STABLE_EXTENSIONS` applies only if `DOWNLOAD_EXTENSIONS` is true: provide a comma separated list of extension identifiers and they will be downloaded and installed on startup (default: "")
## TODOs ## TODOs
* CORS * CORS
* configuration of JNDI connections in the tomcat/custom tomcat configuration in general * configuration of JNDI connections in the tomcat/custom tomcat configuration in general
* default data for gs datadir? * default data for gs datadir?
* possibility to add custom java dependencies (for example the oracle jdbc driver)
* in this context: mount `EXTENSION_DOWNLOAD_DIR` and implement checks to cache extensions that have already been downloaded before?
* log4j properties * log4j properties
* add possibility to add custom fonts * add possibility to add custom fonts
* starting from which version we want to provide geoserver images (maybe 2.15.x?)/backwards compatability * starting from which version we want to provide geoserver images/backwards compatability?
* add a docker-compose demo environment?

View File

@ -12,3 +12,4 @@ services:
- MAXIMUM_MEMORY=2G - MAXIMUM_MEMORY=2G
volumes: volumes:
- ./demo_data/geoserver_data:/opt/geoserver_data/:Z - ./demo_data/geoserver_data:/opt/geoserver_data/:Z
- ./demo_data/additional_libs:/opt/additional_libs:Z # by mounting this we can install libs from host on startup

View File

@ -4,22 +4,44 @@
function download_extension() { function download_extension() {
URL=$1 URL=$1
EXTENSION=$2 EXTENSION=$2
DOWNLOAD_FILE="${ADDITIONAL_LIBS_DIR}geoserver-${GS_VERSION}-${EXTENSION}-plugin.zip"
if [ -e "$DOWNLOAD_FILE" ]; then
echo "$DOWNLOAD_FILE already exists. Skipping download."
else
if curl --output /dev/null --silent --head --fail "${URL}"; then if curl --output /dev/null --silent --head --fail "${URL}"; then
DOWNLOAD_FILE="${EXTENSION_DOWNLOAD_DIR}/geoserver-${GS_VERSION}-${EXTENSION}-plugin.zip"
echo -e "\nDownloading ${EXTENSION}-extension from ${URL}" echo -e "\nDownloading ${EXTENSION}-extension from ${URL}"
wget --progress=bar:force:noscroll -c --no-chec k-certificate "${URL}" -O ${DOWNLOAD_FILE} wget --progress=bar:force:noscroll -c --no-chec k-certificate "${URL}" -O ${DOWNLOAD_FILE}
unzip -q -o ${DOWNLOAD_FILE} -d ${CATALINA_HOME}/webapps/geoserver/WEB-INF/lib
else else
echo "URL does not exist: ${URL}" echo "URL does not exist: ${URL}"
fi fi
fi
} }
# Install stable plugins only if DOWNLOAD_EXTENSIONS is true # Download stable plugins only if DOWNLOAD_EXTENSIONS is true
if [ "$DOWNLOAD_EXTENSIONS" = "true" ]; then if [ "$DOWNLOAD_EXTENSIONS" = "true" ]; then
echo "Starting installation of extensions" echo "Starting download of extensions"
for EXTENSION in $(echo "${STABLE_EXTENSIONS}" | tr ',' ' '); do for EXTENSION in $(echo "${STABLE_EXTENSIONS}" | tr ',' ' '); do
URL="${STABLE_PLUGIN_URL}/geoserver-${GS_VERSION}-${EXTENSION}-plugin.zip" URL="${STABLE_PLUGIN_URL}/geoserver-${GS_VERSION}-${EXTENSION}-plugin.zip"
download_extension ${URL} ${EXTENSION} download_extension ${URL} ${EXTENSION}
done done
echo "Finished installation of extensions" echo "Finished download of extensions"
fi fi
TARGET_LIB_DIR="${CATALINA_HOME}/webapps/geoserver/WEB-INF/lib/"
# Install all extensions that are available in the additional lib dir now
echo "Starting installation of extensions"
for ADDITIONAL_LIB in ${ADDITIONAL_LIBS_DIR}*; do
[ -e "$ADDITIONAL_LIB" ] || continue
if [[ $ADDITIONAL_LIB == *.zip ]]; then
unzip -q -o -d ${TARGET_LIB_DIR} ${ADDITIONAL_LIB} "*.jar"
echo "Installed all jar files from ${ADDITIONAL_LIB}"
elif [[ $ADDITIONAL_LIB == *.jar ]]; then
cp ${ADDITIONAL_LIB} ${TARGET_LIB_DIR}
echo "Installed ${ADDITIONAL_LIB}"
else
echo "Skipping ${ADDITIONAL_LIB}: unknown file extension."
fi
done
echo "Finished installation of extensions"