camptocamp / docker-mapserver

https://hub.docker.com/r/camptocamp/mapserver/
BSD 2-Clause "Simplified" License
42 stars 27 forks source link

Getting Required configuration value MS_MAP_PATTERN not set when we changed our base image from 7.6 to 8.0 #805

Open TWDBrob opened 1 month ago

TWDBrob commented 1 month ago

We modified the base image in our Dockerfile from 7.6 to 8.0

msCGILoadMap(): Web application error. Required configuration value MS_MAP_PATTERN not set.

Our Dockerfile sets both MS_MAP_PATTERN and MS_MAPFILE, btw.

What causes this?

sbrunner commented 1 month ago

It's more a MapServer issue than a Docker packaging issue, but ar you sure that the MS_MAP_PATTERN is set? What about:

docker run <your_image> env | grep MS_
TWDBrob commented 1 month ago

Here's the result of that:

rdennett@twdb.texas.gov@RDENN-LNX-19235:~$ docker run 2616358f20b4 env | grep MS_ 2024-06-05T13:05:18Z a2de404c0ca8 /bin/confd[11]: INFO Backend set to env 2024-06-05T13:05:18Z a2de404c0ca8 /bin/confd[11]: INFO Starting confd 2024-06-05T13:05:18Z a2de404c0ca8 /bin/confd[11]: INFO Backend source(s) set to 2024-06-05T13:05:18Z a2de404c0ca8 /bin/confd[11]: WARNING Found no templates MS_ERRORFILE=stderr MS_MAP_PATTERN=/(.?)mapfiles/(.?).map MS_MAPFILE=/xxxxx_mapfiles/xxxxx.map MS_DEBUGLEVEL=1

The WARNING is due to the fact that I executed that command on my local machine. In reality, the image is run using AWS ECS and the templates are found in S3.

sbrunner commented 1 month ago

The error message didn't say that, but your MS_MAP_PATTERN looks wrong, shouldn't it be /.*mapfiles/.*\.map?

TWDBrob commented 1 month ago

Well, it's supposed to match both

/my_mapfiles/xxx.map and /mapfiles/xxx.map

That said, I am not quite sure why it currently works with

/(.?)mapfiles/(.?).map

instead of

/(.?)+mapfiles/(.?)+.map

also, I am running this locally with bind mounts to some local directories and all I did was change the base image from 7.6 to 8.0 and it's working fine. We're looking into that and will close this if appropriate.

TWDBrob commented 1 month ago

My template links were pointed back at production instead of my local environment which is why it was working. I fixed it to use localhost and now I am getting the expected error

TWDBrob commented 1 month ago

My C is kind of rusty, but the MapServer code appears to throw the error I see when ms_map_pattern is null. It's retrieved in mapservutil.c at this line:

const char *ms_map_pattern = CPLGetConfigOption("MS_MAP_PATTERN", NULL);

From https://gdal.org/api/cpl.html#_CPPv418CPLGetConfigOptionPKcPKc, we see that function searches for a key/value pair set with CPLSetConfigOption() or in the list of environment variables.

when I exec into my local docker container and run

env | grep MS_

I get

MS_ERRORFILE=stderr MS_MAP_PATTERN=/(.?)mapfiles/(.?).map MS_MAPFILE=/my_mapfiles/xxx.map MS_DEBUGLEVEL=1