diff --git a/docker/default.config.yml b/docker/default.config.yml index 81d9e2883..29174bbf5 100644 --- a/docker/default.config.yml +++ b/docker/default.config.yml @@ -38,13 +38,14 @@ server: bind: host: 0.0.0.0 port: 80 - url: http://localhost:5000 + url: ${PYGEOAPI_SERVER_URL:-http://localhost:5000} mimetype: application/json; charset=UTF-8 encoding: utf-8 gzip: false language: en-US cors: true pretty_print: true + admin: ${PYGEOAPI_SERVER_ADMIN:-false} limit: 10 # templates: /path/to/templates map: diff --git a/docs/source/running-with-docker.rst b/docs/source/running-with-docker.rst index afd9533f3..87a644bb4 100644 --- a/docs/source/running-with-docker.rst +++ b/docs/source/running-with-docker.rst @@ -71,6 +71,30 @@ Or you can create a ``Dockerfile`` extending the base image and **copy** in your A corresponding example can be found in https://github.com/geopython/demo.pygeoapi.io/tree/master/services/pygeoapi_master +Environment Variables for Configuration +--------------------------------------- + +The base Docker image supports two additional environment variables for configuring the `pygeoapi` server behavior: + +1. **`PYGEOAPI_SERVER_URL`**: + This variable sets the `pygeoapi` server URL in the configuration. It is useful for dynamically configuring the server URL during container deployment. For example: + + .. code-block:: bash + + docker run -p 2018:80 -e PYGEOAPI_SERVER_URL='http://localhost:2018' -it geopython/pygeoapi + + This ensures the service URLs in the configuration file are automatically updated to reflect the specified URL. + +2. **`PYGEOAPI_SERVER_ADMIN`**: + This boolean environment variable enables or disables the `pygeoapi` Admin API. By default, the Admin API is disabled. To enable it: + + .. code-block:: bash + + docker run -p 5000:80 -e PYGEOAPI_SERVER_ADMIN=true -it geopython/pygeoapi + + This does not enable hot reloading of the `pygoeapi` configuration. To learn more about the Admin API see :ref:`admin-api`. + + Deploying on a sub-path ----------------------- diff --git a/tests/pygeoapi-test-config-envvars.yml b/tests/pygeoapi-test-config-envvars.yml index f8b7af2e1..3784f13dd 100644 --- a/tests/pygeoapi-test-config-envvars.yml +++ b/tests/pygeoapi-test-config-envvars.yml @@ -31,7 +31,7 @@ server: bind: host: 0.0.0.0 port: ${PYGEOAPI_PORT} - url: ${PYGEOAPI_URL:-http://localhost:5000/} + url: ${PYGEOAPI_SERVER_URL:-http://localhost:5000/} mimetype: application/json; charset=UTF-8 encoding: utf-8 language: en-US diff --git a/tests/test_config.py b/tests/test_config.py index 2b93a30fd..b526c9455 100644 --- a/tests/test_config.py +++ b/tests/test_config.py @@ -59,7 +59,7 @@ def test_config_envvars(): 'pygeoapi default instance my title' assert config['server']['api_rules']['url_prefix'] == '' - os.environ['PYGEOAPI_URL'] = 'https://localhost:5000' + os.environ['PYGEOAPI_SERVER_URL'] = 'https://localhost:5000' os.environ['PYGEOAPI_PREFIX'] = 'v1' with open(get_test_file_path('pygeoapi-test-config-envvars.yml')) as fh: