I am using GeoServer 2.16.0 docker image build by myself based on kartoza's dockerfile.
The only pre-configuration is done via environment files, e.g. geoserver.env
:
ENABLE_JSONP=true
FOOTPRINTS_DATA_DIR=/opt/footprints_dir
GEOSERVER_ADMIN_PASSWORD=myawesomegeoserver
GEOSERVER_DATA_DIR=/opt/geoserver/data_dir
GEOSERVER_NODE_OPTS="id:$hostname - ($host_ip);background:red;color:white"
GEOWEBCACHE_CACHE_DIR=/opt/geoserver/data_dir/gwc
#JAVA_OPTS="-Duser.country=US -Duser.language=en"
MAX_FILTER_RULES=20
OPTIMIZE_LINE_WIDTH=false
I would like to configure more, e.g. workspaces, stores, but cannot find any according documentation.
Is there any better way than the following?
- Configuring a running container having the
DATA_DIR
mounted - Create an own image based in kartoza's and add the
DATA_DIR
content?
Solution (16.02.2021)
I added the following two lines to my dockerfile:
COPY ./data_dir_init /tmp/data_dir_init
COPY ./init-workspace.sh /scripts
The init-workspace.sh contains the following:
SETUP_LOCKFILE="${GEOSERVER_DATA_DIR}/.init_data_dir.lock"
if [ -f "${SETUP_LOCKFILE}" ]; then
echo -e "\n\n Skip GeoServer init - already done\n\n"
exit 0
fi
if [ "${DEBUG}" ]; then
set -e
set -x
fi
echo -e "\n\nStarting init of GeoServer data dir\n\n"
cp --verbose --recursive /tmp/data_dir_init/{styles,workspaces} $GEOSERVER_DATA_DIR
cp --verbose /tmp/data_dir_init/{csw,global,logging,wms,wps}.xml $GEOSERVER_DATA_DIR
mkdir--verbose --parents $GEOSERVER_DATA_DIR/data
if [ ! ${DEBUG} ]; then
rm --recursive --verbose /tmp/data_dir_init
fi
# Put lock file to make sure data directory is not reinitialized on restart
touch ${SETUP_LOCKFILE}
The folder data_dir_init
contains all content from the first session, when I startet an empty geoserver instance and created the base set-up I needed.
Best Answer
Either of those would work, or you could use the REST API to add the workspaces and stores when building your own image.