3

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?

  1. Configuring a running container having the DATA_DIR mounted
  2. 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.

0

Either of those would work, or you could use the REST API to add the workspaces and stores when building your own image.

3
  • That's correct. In the end, I used the "empty" image with a mounted DATA_DIR volume and created my initial set-up. This set-up is "installed" during image creation.
    – Eike
    Jan 7 at 11:21
  • @Eike could you please be more specific about how to use DATA_DIR to inyect the initial set-up on image build? Feb 3 at 22:50
  • @luishromero: I added some more details to the question about my solution.
    – Eike
    Feb 16 at 10:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.