Merge pull request #31 from mbosecke/jndi
Added support for a PostgreSQL JNDI resource.pull/34/head
commit
ec6273055a
10
Dockerfile
10
Dockerfile
|
|
@ -31,7 +31,7 @@ ENV CATALINA_OPTS="\$EXTRA_JAVA_OPTS \
|
||||||
# init
|
# init
|
||||||
RUN apt update \
|
RUN apt update \
|
||||||
&& apt -y upgrade \
|
&& apt -y upgrade \
|
||||||
&& apt install -y --no-install-recommends openssl unzip gdal-bin wget curl openjdk-11-jdk \
|
&& apt install -y --no-install-recommends openssl unzip gdal-bin wget curl openjdk-11-jdk gettext \
|
||||||
&& apt clean \
|
&& apt clean \
|
||||||
&& rm -rf /var/cache/apt/* \
|
&& rm -rf /var/cache/apt/* \
|
||||||
&& rm -rf /var/lib/apt/lists/*
|
&& rm -rf /var/lib/apt/lists/*
|
||||||
|
|
@ -92,6 +92,9 @@ ENV ADDITIONAL_LIBS_DIR=/opt/additional_libs/
|
||||||
ENV ADDITIONAL_FONTS_DIR=/opt/additional_fonts/
|
ENV ADDITIONAL_FONTS_DIR=/opt/additional_fonts/
|
||||||
ENV SKIP_DEMO_DATA=false
|
ENV SKIP_DEMO_DATA=false
|
||||||
ENV ROOT_WEBAPP_REDIRECT=false
|
ENV ROOT_WEBAPP_REDIRECT=false
|
||||||
|
ENV POSTGRES_JNDI_ENABLED=false
|
||||||
|
ENV CONFIG_DIR=/opt/config
|
||||||
|
ENV CONFIG_OVERRIDES_DIR=/opt/config_overrides
|
||||||
|
|
||||||
EXPOSE 8080
|
EXPOSE 8080
|
||||||
|
|
||||||
|
|
@ -104,6 +107,8 @@ COPY --from=download /tmp/geoserver $CATALINA_HOME/webapps/geoserver
|
||||||
RUN mv $CATALINA_HOME/webapps/geoserver/WEB-INF/lib/marlin-*.jar $CATALINA_HOME/lib/marlin.jar \
|
RUN mv $CATALINA_HOME/webapps/geoserver/WEB-INF/lib/marlin-*.jar $CATALINA_HOME/lib/marlin.jar \
|
||||||
&& mkdir -p $GEOSERVER_DATA_DIR
|
&& mkdir -p $GEOSERVER_DATA_DIR
|
||||||
|
|
||||||
|
RUN mv $CATALINA_HOME/webapps/geoserver/WEB-INF/lib/postgresql-*.jar $CATALINA_HOME/lib/
|
||||||
|
|
||||||
COPY $GS_DATA_PATH $GEOSERVER_DATA_DIR
|
COPY $GS_DATA_PATH $GEOSERVER_DATA_DIR
|
||||||
COPY $ADDITIONAL_LIBS_PATH $GEOSERVER_LIB_DIR
|
COPY $ADDITIONAL_LIBS_PATH $GEOSERVER_LIB_DIR
|
||||||
COPY $ADDITIONAL_FONTS_PATH /usr/share/fonts/truetype/
|
COPY $ADDITIONAL_FONTS_PATH /usr/share/fonts/truetype/
|
||||||
|
|
@ -111,6 +116,9 @@ COPY $ADDITIONAL_FONTS_PATH /usr/share/fonts/truetype/
|
||||||
# cleanup
|
# cleanup
|
||||||
RUN rm -rf /tmp/*
|
RUN rm -rf /tmp/*
|
||||||
|
|
||||||
|
# Add default configs
|
||||||
|
ADD config $CONFIG_DIR
|
||||||
|
|
||||||
# copy scripts
|
# copy scripts
|
||||||
COPY *.sh /opt/
|
COPY *.sh /opt/
|
||||||
RUN chmod +x /opt/*.sh
|
RUN chmod +x /opt/*.sh
|
||||||
|
|
|
||||||
18
README.md
18
README.md
|
|
@ -128,6 +128,24 @@ docker run -it -p 80:8080 \
|
||||||
|
|
||||||
**Note:** Do not change the target value!
|
**Note:** Do not change the target value!
|
||||||
|
|
||||||
|
|
||||||
|
## How to enable a PostgreSQL JNDI resource?
|
||||||
|
|
||||||
|
To enable a PostgreSQL JNDI resource, provide the following environment variables:
|
||||||
|
|
||||||
|
* ``POSTGRES_JNDI_ENABLED`` to ``true``
|
||||||
|
* ``POSTGRES_HOST``
|
||||||
|
* ``POSTGRES_PORT`` (optional; defaults to 5432)
|
||||||
|
* ``POSTGRES_DB``
|
||||||
|
* ``POSTGRES_USERNAME``
|
||||||
|
* ``POSTGRES_PASSWORD``
|
||||||
|
* ``POSTGRES_JNDI_RESOURCE_NAME`` (optional; defaults to ``jdbc/postgres``)
|
||||||
|
|
||||||
|
In geoserver, you can then reference this JNDI resource using the name `java:comp/env/jdbc/postgres` (if using default).
|
||||||
|
|
||||||
|
For advanced customization of the connection pool, you can provide your own customized "context.xml"
|
||||||
|
file to Apache Tomcat by mounting it to the container at ``/opt/config_overrides/context.xml``.
|
||||||
|
|
||||||
## How to use the docker-compose demo?
|
## How to use the docker-compose demo?
|
||||||
|
|
||||||
The ``docker-compose-demo.yml`` to build with your own data directory and extensions.
|
The ``docker-compose-demo.yml`` to build with your own data directory and extensions.
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,20 @@
|
||||||
|
<Context antiResourceLocking="false" privileged="true" >
|
||||||
|
<Resource name="${POSTGRES_JNDI_RESOURCE_NAME}"
|
||||||
|
auth="Container"
|
||||||
|
type="javax.sql.DataSource"
|
||||||
|
driverClassName="org.postgresql.Driver"
|
||||||
|
url="jdbc:postgresql://${POSTGRES_HOST}:${POSTGRES_PORT}/${POSTGRES_DB}"
|
||||||
|
username="${POSTGRES_USERNAME}"
|
||||||
|
password="${POSTGRES_PASSWORD}"
|
||||||
|
maxTotal="25"
|
||||||
|
initialSize="0"
|
||||||
|
minIdle="0"
|
||||||
|
maxIdle="8"
|
||||||
|
maxWaitMillis="-1"
|
||||||
|
timeBetweenEvictionRunsMillis="30000"
|
||||||
|
minEvictableIdleTimeMillis="60000"
|
||||||
|
testWhileIdle="true"
|
||||||
|
validationQuery="SELECT 1"
|
||||||
|
rollbackOnReturn="true"
|
||||||
|
/>
|
||||||
|
</Context>
|
||||||
|
|
@ -13,6 +13,22 @@ services:
|
||||||
- INSTALL_EXTENSIONS=true
|
- INSTALL_EXTENSIONS=true
|
||||||
- STABLE_EXTENSIONS=wps,csw
|
- STABLE_EXTENSIONS=wps,csw
|
||||||
- EXTRA_JAVA_OPTS=-Xms1G -Xmx2G
|
- EXTRA_JAVA_OPTS=-Xms1G -Xmx2G
|
||||||
|
- POSTGRES_JNDI_ENABLED=true
|
||||||
|
- POSTGRES_HOST=postgis
|
||||||
|
- POSTGRES_PORT=5432
|
||||||
|
- POSTGRES_DB=geoserver
|
||||||
|
- POSTGRES_USERNAME=geoserver
|
||||||
|
- POSTGRES_PASSWORD=geoserver
|
||||||
|
- POSTGRES_JNDI_RESOURCE_NAME=jdbc/postgres
|
||||||
volumes:
|
volumes:
|
||||||
- ./geoserver_data:/opt/geoserver_data/:Z
|
- ./geoserver_data:/opt/geoserver_data/:Z
|
||||||
- ./additional_libs:/opt/additional_libs:Z # by mounting this we can install libs from host on startup
|
- ./additional_libs:/opt/additional_libs:Z # by mounting this we can install libs from host on startup
|
||||||
|
postgis:
|
||||||
|
image: postgis/postgis:16-3.4-alpine
|
||||||
|
ports:
|
||||||
|
- 5555:5432
|
||||||
|
environment:
|
||||||
|
POSTGRES_USER: geoserver
|
||||||
|
POSTGRES_PASSWORD: geoserver
|
||||||
|
volumes:
|
||||||
|
- ./postgis/postgresql_data:/var/lib/postgresql/data:Z
|
||||||
21
startup.sh
21
startup.sh
|
|
@ -90,5 +90,26 @@ if [ "${CORS_ENABLED}" = "true" ]; then
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [ "${POSTGRES_JNDI_ENABLED}" = "true" ]; then
|
||||||
|
|
||||||
|
# Set up some default values
|
||||||
|
if [ -z "${POSTGRES_JNDI_RESOURCE_NAME}" ]; then
|
||||||
|
export POSTGRES_JNDI_RESOURCE_NAME="jdbc/postgres"
|
||||||
|
fi
|
||||||
|
if [ -z "${POSTGRES_PORT}" ]; then
|
||||||
|
export POSTGRES_PORT="5432"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Use a custom "context.xml" if the user mounted one into the container
|
||||||
|
if [ -d "${CONFIG_OVERRIDES_DIR}" ] && [ -f "${CONFIG_OVERRIDES_DIR}/context.xml" ]; then
|
||||||
|
echo "Installing configuration override for context.xml with substituted environment variables"
|
||||||
|
envsubst < "${CONFIG_OVERRIDES_DIR}"/context.xml > "${CATALINA_HOME}/conf/context.xml"
|
||||||
|
else
|
||||||
|
# Otherwise use the default
|
||||||
|
echo "Installing default context.xml with substituted environment variables"
|
||||||
|
envsubst < "${CONFIG_DIR}"/context.xml > "${CATALINA_HOME}/conf/context.xml"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
# start the tomcat
|
# start the tomcat
|
||||||
exec $CATALINA_HOME/bin/catalina.sh run
|
exec $CATALINA_HOME/bin/catalina.sh run
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue