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::
20
25
21
-
python3 demo.py
26
+
$ sudo apt-get install python3-gdal
22
27
23
28
24
-
PyWPS example service
25
-
========================
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`::
26
30
27
-
This is a simple example service written using PyWPS. It has been tested with
The app depends on PyWPS and several other libraries that are listed in
34
-
``requirements.txt``. You can install them with pip::
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
+
106
+
$ docker run -p 8081:8081 -it pywps/gunicorn-alpine:latest
To build the image (inside the folder with the Dockerfile)::
120
+
This is the complete stack intented for production, to have a stack we require to use ``docker-compose``
121
+
to build two images: ``pywps/gunicorn-alpine:latest`` and ``pywps/nginx-alpine:latest``
90
122
91
-
$ docker build -t pywps4-demo .
123
+
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
124
93
125
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::
126
+
$ cd docker/alpine/nginx/Dockerfile
127
+
$ docker build -t pywps/nginx-alpine:latest .
95
128
129
+
Then the stack can be started using docker compose::
96
130
97
-
$ docker run -e GU_WORKERS=10 -p 80:80 -it pywps4-demo:nginx
131
+
$ docker-compose up
98
132
99
133
100
134
In this case pywps (only the WPS) will be avalable on::
@@ -103,11 +137,77 @@ In this case pywps (only the WPS) will be avalable on::
103
137
http://localhost
104
138
105
139
140
+
Flask-Ubuntu (basic)
141
+
--------------------
142
+
143
+
The same as ``Flask-Ubuntu`` but using phusion image (ubuntu 18.04)::
144
+
145
+
146
+
$ cd docker/ubuntu/flask
147
+
$ docker build -t pywps/flask-ubuntu:latest .
148
+
149
+
And to run it::
150
+
151
+
$ docker run -p 5000:5000 pywps/flask-ubuntu
152
+
153
+
154
+
Nginx-Ubuntu (production)
155
+
-------------------------
156
+
157
+
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::
158
+
159
+
160
+
$ cd docker/ubuntu/nginx
161
+
$ docker build -t pywps/nginx-ubuntu .
162
+
163
+
And to run it::
164
+
165
+
$ docker run -p 80:80 pywps/nginx-ubuntu
166
+
167
+
It is possible to set the number of Gunicorn workers:
168
+
169
+
* GU_WORKERS - Numer or workers. (default: 5)
170
+
171
+
e.g::
172
+
173
+
$ docker run -e GU_WORKERS=10 -p 80:80 pywps/nginx-ubuntu
174
+
175
+
176
+
177
+
Volumes
178
+
-------
179
+
180
+
181
+
Named volumes allow for container content to be available in the host system. The most important folders in pywps containers are:
182
+
183
+
* /pywps-flask/logs
184
+
* /pywps-flask/outputs
185
+
* /pywps-flask/processes
186
+
187
+
And file:
188
+
* /pywps-flask/pywps.cfg
189
+
190
+
Named volumes need to be created prior to ``docker run``::
191
+
192
+
$ docker volume create pywps_logs
193
+
$ docker volume create pywps_outputs
194
+
$ docker volume create pywps_processes
195
+
196
+
To check the path on the host to volume and other information::
197
+
106
198
199
+
$ docker volume ls pywps_processes
107
200
108
201
202
+
To run a docker will all the volumes available in the host::
109
203
204
+
$ docker run -p 5000:5000 -v pywps_logs:/pywps-flask/pywps_logs \
0 commit comments