You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
For Debian based systems you will need to install GDAL with::
22
25
26
+
$ sudo apt-get install python3-gdal
23
27
24
-
PyWPS example service
25
-
========================
26
28
27
-
This is a simple example service written using PyWPS. It has been tested with
28
-
QGIS 1.8.
29
+
When using only using `requirement.txt`, the `pywps-flask` will run for the directory that was pulled from github, for a system wise installation is it advisable to use `setup.py`
The app depends on PyWPS and several other libraries that are listed in
34
-
``requirements.txt``. You can install them with pip::
35
35
36
-
$ pip install -r requirements.txt
36
+
=======
37
+
Running
38
+
=======
37
39
38
-
For Debian based systems you will need to install GDAL with::
40
+
Simply run the python file::
39
41
40
-
$ sudo apt-get install python-gdal
42
+
$ python3 demo.py -a
41
43
42
-
For Windows systems install you need to install Shapely and GDAL by using Python Wheels.
43
-
If you have Shapely already installed you might have to uninstall it and installed as a Wheel for it to work::
44
+
The flag `-a` will bind to the ip range `0.0.0.0` and is normally the safest option access to `pypwps-flask`
44
45
45
-
Download the corresponding wheel for Shapely: http://www.lfd.uci.edu/~gohlke/pythonlibs/#shapely
46
+
The `-d` option will run pywps-flask as daemon and to stop it is necessary to determine the PID and kill it, one trick is to use fuser to determine PID, and then use it to kill the process
46
47
47
-
Download the corresponding wheel for GDAL: http://www.lfd.uci.edu/~gohlke/pythonlibs/#gdal
48
+
$ fuser tcp/5000
49
+
$ kill -15 <PID RETURNED PREVIOUSLY>
48
50
49
-
$ pip install wheel
50
51
51
-
$ pip install Shapely?x.x.x?cpxx?none?win_xxx.whl
52
52
53
-
$ pip install GDAL?x.x.x?cpxx?none?win_xxx.whl
53
+
==============
54
+
Docker images
55
+
==============
54
56
57
+
The docker folder contains 2 subfolders, each subfolder contains a differente pywps implementation.
55
58
56
-
Running
57
-
-------
58
-
Simply run the python file::
59
+
Folder ``flask`` has the default pywps-flask implementation using only Flask while folder ``nginx`` implements pywps using Nginx and Green unicorn as WSGI server. While folder ``ubuntu`` has the same images but using phusion image (ubuntu 18.04)
60
+
59
61
60
-
$ python demo.py
61
62
63
+
Flask-Alpine (basic)
64
+
--------------------
62
65
63
-
Docker
64
-
------
65
-
The docker folder contains 2 subfolders, each subfolder contains a differente pywps implementation. Folder ``flask``
66
-
has the default pywps-flask implementation using only Flask while folder ``nginx`` implements pywps using Nginx and Green unicorn as WSGI server.
66
+
Basic pywps image is based on Alpine 3.8 and will run the native Flask service, this is not apropriate for production. The docker file can be found in: ``docker/alpine/flask/Dockerfile``
67
67
68
68
69
-
Docker-flask
70
-
------------
71
69
72
70
To build the image (inside the folder with the Dockerfile)::
73
71
74
-
$ docker build -t pywps4-demo:latest .
72
+
$ docker build -t pywps/flask-alpine .
75
73
76
74
And to run it::
77
75
78
-
$ docker run -p 5000:5000 pywps4-demo:latest
76
+
$ docker run -p 5000:5000 pywps/flask-alpine:latest
79
77
80
78
81
79
Pywps will be available in the following URL::
82
80
83
81
$ http://localhost:5000
84
82
85
83
86
-
Docker-nginx
84
+
85
+
Gunicorn-Alpine (production)
86
+
---------------------------
87
+
88
+
This image implements the previous ``flask-alpine image`` (you need to build it first, or it will be automatically pulled from dockerhub) but wrapping flask in a WSGI server (gunicorn) where each worker runs a an app. This image allows for the following environment variables::
89
+
90
+
* GU_WORKERS - Numer or workers. Gunicorn uses a set of workers to run pywps (normally ``workers = (2 * cpu) + 1``). (default: 5)
91
+
* GU_PORT - Port running Gunicorn (default:8081)
92
+
93
+
94
+
95
+
Gunicorn-Alpine is locate in folder ``docker/alpine/gunicorn/Dockerfile``
96
+
97
+
This image can already be implemented in production but it is advisable to use Nginx for HTTP load balance and Gunicorn as WSGI server (see below)
98
+
99
+
To build the image (inside the folder with the Dockerfile)::
100
+
101
+
$ docker build -t pywps/gunicorn-alpine:latest .
102
+
103
+
104
+
And to run it::
105
+
$ docker run -p 8081:8081 -it pywps/gunicorn-alpine:latest
To build the image (inside the folder with the Dockerfile)::
118
+
This is the complete stack intented for production, to have a stack we require to use ``docker-compose``
119
+
to build two images: ``pywps/gunicorn-alpine:latest`` and ``pywps/nginx-alpine:latest``
90
120
91
-
$ docker build -t pywps4-demo .
121
+
Those images will be pulled from dockerhub, but they can compiled locally by building Flask-Alpine, Gunicron-Alpine and Nginx-Alpine, in this case only showing for nginx
92
122
93
123
94
-
Gunicorn uses a set of workers to run pywps (normally ``workers = (2 * cpu) + 1``), the default value used was 5 but it can be overwritten by setting the env flag GU_WORKERS::
124
+
$ cd docker/alpine/nginx/Dockerfile
125
+
$ docker build -t pywps/nginx-alpine:latest .
95
126
127
+
Then the stack can be started using docker compose::
96
128
97
-
$ docker run -e GU_WORKERS=10 -p 80:80 -it pywps4-demo:nginx
129
+
$ docker-compose up
98
130
99
131
100
132
In this case pywps (only the WPS) will be avalable on::
@@ -103,8 +135,85 @@ In this case pywps (only the WPS) will be avalable on::
103
135
http://localhost
104
136
105
137
138
+
Flask-Ubuntu (basic)
139
+
--------------------
140
+
141
+
The same as ``Flask-Ubuntu`` but using phusion image (ubuntu 18.04)
142
+
143
+
144
+
$ cd docker/ubuntu/flask/Dockerfile
145
+
$ docker build -t pywps/flask-ubuntu:latest .
146
+
147
+
And to run it::
148
+
149
+
$ docker run -p 5000:5000 pywps/flask-ubuntu
150
+
151
+
152
+
Nginx-Ubuntu (production)
153
+
-------------------------
154
+
155
+
This image is based on ``Flask-Ubuntu`` and will require it (either build locally or pull from dockerhub). This image has Nginx and Gunicorn totally integrated as services in a docker image
156
+
157
+
158
+
$ cd docker/ubuntu/nginx/Dockerfile
159
+
$ docker build -t pywps/nginx-ubuntu
160
+
161
+
And to run it::
162
+
163
+
$ docker run -p 80:80 pywps/nginx-ubuntu
164
+
165
+
It is possible to set the number of Gunicorn workers::
166
+
167
+
* GU_WORKERS - Numer or workers. (default: 5)
168
+
169
+
e.g::
170
+
171
+
$ docker run -e GU_WORKERS=10 -p 80:80 pywps/nginx-ubuntu
172
+
173
+
174
+
175
+
Volumes
176
+
-------
177
+
178
+
179
+
Named volumes allow for container content to be available in the host system. The most important folders in pywps containers are:
180
+
181
+
* /pywps-flask/logs
182
+
* /pywps-flask/outputs
183
+
* /pywps-flask/processes
184
+
185
+
And file:
186
+
* /pywps-flask/pywps.cfg
187
+
188
+
Named volumes need to be created prior to ``docker run``
189
+
190
+
$ docker volume create pywps_logs
191
+
$ docker volume create pywps_outputs
192
+
$ docker volume create pywps_processes
193
+
194
+
To check the path on the host to volume and other information::
195
+
196
+
197
+
$ docker volume ls pywps_processes
198
+
199
+
200
+
To run a docker will all the volumes available in the host::
201
+
202
+
$ docker run -p 5000:5000 -v pywps_logs:/pywps-flask/pywps_logs \
0 commit comments