diff --git a/Dockerfile b/Dockerfile index 7791e06..9471eeb 100644 --- a/Dockerfile +++ b/Dockerfile @@ -13,7 +13,8 @@ ENV BASEDIR=/data/web/geomet-climate-nightly \ # GEOMET_CLIMATE_ES_PASSWORD=bar # ES credentials loaded from host env GEOMET_CLIMATE_ES_URL=https://${GEOMET_CLIMATE_ES_USERNAME}:${GEOMET_CLIMATE_ES_PASSWORD}@localhost:9200 \ - GEOMET_CLIMATE_OWS_DEBUG=5 + GEOMET_CLIMATE_OWS_DEBUG=5 \ + MAPSERVER_CONFIG_FILE=${GEOMET_CLIMATE_BASEDIR}/mapserver.conf # GEOMET_CLIMATE_OWS_LOG=/tmp/geomet-climate-ows.log WORKDIR $BASEDIR diff --git a/geomet_climate/mapfile.py b/geomet_climate/mapfile.py index 2e5e0a8..b5640ca 100755 --- a/geomet_climate/mapfile.py +++ b/geomet_climate/mapfile.py @@ -43,6 +43,12 @@ THISDIR = os.path.dirname(os.path.realpath(__file__)) +MAPSERVER_CONFIG = f'''CONFIG + ENV + MS_MAP_PATTERN "{BASEDIR}/mapfile/.*" + END +END +''' def gen_web_metadata(m, c, service, url): """ @@ -396,6 +402,12 @@ def mapfile(): def generate(ctx, service, layer): """generate mapfile""" + # generate MapServer config file if not present + if not os.path.exists(os.path.join(BASEDIR, 'mapserver.conf')): + os.makedirs(BASEDIR, exist_ok=True) + with open(os.path.join(BASEDIR, 'mapserver.conf'), 'w+') as f: + f.write(MAPSERVER_CONFIG) + output_dir = '{}{}mapfile'.format(BASEDIR, os.sep) template_dir = '{}{}mapfile{}template'.format(BASEDIR, os.sep, os.sep)