Files
pygeoapi/docker
Massimo Di Stefano 2d4d8e6646 docker: upgrade ubuntu version (#1093)
* docker: upgrade ubuntu version

Upgrade rhe ubuntu version used in the main Dockerfile to latest stable version `20.04`

* Update Dockerfile

amended ubuntu version 20 -> 22

but then the following error:

```
0 added, 0 removed; done.
Running hooks in /etc/ca-certificates/update.d...
done.
Processing triggers for dbus (1.12.20-2ubuntu4.1) ...
gpg: error running '/usr/bin/gpg-agent': probably not installed
gpg: failed to start agent '/usr/bin/gpg-agent': Configuration error
gpg: can't connect to the agent: Configuration error
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/softwareproperties/shortcuthandler.py", line 423, in add_key
PPA publishes dbgsym, you may need to include 'main/debug' component
Repository: 'deb https://ppa.launchpadcontent.net/ubuntugis/ubuntugis-unstable/ubuntu/ jammy main'
Description:
Unstable releases of Ubuntu GIS packages. These releases are more bleeding edge and while generally they should work well, they dont receive the same amount of quality assurance as our stable releases do.
More info: https://launchpad.net/~ubuntugis/+archive/ubuntu/ubuntugis-unstable
Adding repository.
Adding deb entry to /etc/apt/sources.list.d/ubuntugis-ubuntu-ubuntugis-unstable-jammy.list
Adding disabled deb-src entry to /etc/apt/sources.list.d/ubuntugis-ubuntu-ubuntugis-unstable-jammy.list
Adding key to /etc/apt/trusted.gpg.d/ubuntugis-ubuntu-ubuntugis-unstable.gpg with fingerprint 6B827C12C2D425E227EDCA75089EBE08314DF160
    subprocess.run(cmd.split(), check=True, input=keys)
  File "/usr/lib/python3.10/subprocess.py", line 524, in run
    raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command '['gpg', '-q', '--no-options', '--no-default-keyring', '--batch', '--keyring', '/etc/apt/trusted.gpg.d/ubuntugis-ubuntu-ubuntugis-unstable.gpg', '--homedir', '/tmp/tmpjlr98185', '--import']' returned non-zero exit status 2.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/bin/add-apt-repository", line 364, in <module>
    sys.exit(0 if addaptrepo.main() else 1)
  File "/usr/bin/add-apt-repository", line 357, in main
    shortcut.add()
  File "/usr/lib/python3/dist-packages/softwareproperties/shortcuthandler.py", line 222, in add
    self.add_key()
  File "/usr/lib/python3/dist-packages/softwareproperties/shortcuthandler.py", line 425, in add_key
    raise ShortcutException(e)
softwareproperties.shortcuthandler.ShortcutException: Command '['gpg', '-q', '--no-options', '--no-default-keyring', '--batch', '--keyring', '/etc/apt/trusted.gpg.d/ubuntugis-ubuntu-ubuntugis-unstable.gpg', '--homedir', '/tmp/tmpjlr98185', '--import']' returned non-zero exit status 2.
````

Removing the ubuntugis PPA  build without error - is ubuntugis a requirements? probably Jammy has up-to-date packages for pygeoapi dependencies

* Update Dockerfile

removing ubuntugis PPA

* Update Dockerfile

adding  `python3-pytest` and `python3-pyld`  dependencies

* Update Dockerfile

* Update Dockerfile

* fixing docker environment with suggested changes

* replace ubuntu version with codename

* Update .dockerignore

* Update Dockerfile

* Update Dockerfile

* Update Dockerfile

* Update entrypoint.sh

skip the SensorThings and other tests that require a local server

Co-authored-by: Just van den Broecke <just@justobjects.nl>
2023-01-18 15:04:36 +01:00
..

pygeoapi Docker How To

Docker Image geopython/pygeoapi:latest and versions are available from DockerHub.

Each Docker Image contains a default configuration default.config.yml with the project's test data and OGC API dataset collections.

You can override this default config via Docker Volume mapping or by extending the Docker Image and copying in your config. See an example for the geoapi demo server for the latter method.

https://github.com/geopython/demo.pygeoapi.io/tree/master/services Depending on your config you may need specific backends to be available.

Background

The version tagged latest is automatically built whenever code in the master branch of this GitHub repo changes (autobuild). This also cascades to updating the pygeoapi demo service.

So the chain is:

 (git push to master) --> (DockerHub Image autobuild) --> (demo server redeploy)

There are a number of examples at several examples.

Installation

Install Docker (Ubuntu)

sudo apt-get install apt-transport-https
sudo apt-get install ca-certificates
sudo apt-get install curl
sudo apt-get install gnupg-agent
sudo apt-get install software-properties-common
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add 
sudo apt-key fingerprint 0EBFCD88
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
sudo apt-get update
sudo apt-get install docker-ce docker-ce-cli containerd.io
sudo systemctl enable docker

Pull dockerhub repo

docker pull geopython/pygeoapi

Create your own my.config.yml (https://github.com/geopython/pygeoapi/blob/master/docker/examples/simple/my.config.yml) in home directory

Run/Create Container

$ sudo docker run --name geoapi -p 5000:80 -v $(pwd)/my.config.yml:/pygeoapi/local.config.yml -it geopython/pygeoapi

Go to http://localhost:5000/ and should be up and running.

Running - Basics

By default this Image will start a pygeoapi Docker Container using gunicorn on internal port 80.

To run with default built-in config and data:

	docker run -p 5000:80 -it geopython/pygeoapi run
	# or simply
	docker run -p 5000:80 -it geopython/pygeoapi

    # then browse to http://localhost:5000/

You can also run all unit tests to verify:

	docker run -it geopython/pygeoapi test

Running - Overriding the default config

Normally you would override the default.config.yml with your own pygeoapi config. This can be effected best via Docker Volume Mapping.

For example if your config is in my.config.yml:

	docker run -p 5000:80 -v $(pwd)/my.config.yml:/pygeoapi/local.config.yml -it geopython/pygeoapi

But better/cleaner is to use docker-compose. Something like:

version: "3"

services:

  pygeoapi:
    image: geopython/pygeoapi:latest

    volumes:
      - ./my.config.yml:/pygeoapi/local.config.yml

Or you can create a Dockerfile extending the base Image and COPY in your config:

FROM geopython/pygeoapi:latest

COPY ./my.config.yml /pygeoapi/local.config.yml

See how the demo server is setup this way at https://github.com/geopython/demo.pygeoapi.io/tree/master/services/pygeoapi_master

Running - Running on a sub-path

By default the pygeoapi Docker Image will run from the root path /. If you need to run from a sub-path and have all internal URLs correct you need to set SCRIPT_NAME environment variable.

For example to run with my.config.yml on http://localhost:5000/mypygeoapi:

	docker run -p 5000:80 -e SCRIPT_NAME='/mypygeoapi' -v $(pwd)/my.config.yml:/pygeoapi/local.config.yml -it geopython/pygeoapi
	# browse to http://localhost:5000/mypygeoapi

Or within a docker-compose.yml full example:

version: "3"

services:

  pygeoapi:
    image: geopython/pygeoapi:latest

    volumes:
      - ./my.config.yml:/pygeoapi/local.config.yml

    ports:
      - "5000:80"

    environment:
     - SCRIPT_NAME=/pygeoapi


See pygeoapi demo service for an full example.